#Leetcode链表
D-wade.陈
哭着来到这个世界,就要笑着离开。
展开
-
Leetcode链表5
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */int kthToLast(struct ListNode* head, int k){ struct ListNode* slow_p=head,*p=head; while(k--){ p=p->next; } .原创 2021-04-06 21:07:01 · 227 阅读 · 1 评论 -
Leetcode链表4
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct ListNode* mergeInBetween(struct ListNode* list1, int a, int b, struct ListNode* list2){ struct ListNode *fast = list1; .原创 2021-02-17 20:56:47 · 182 阅读 · 0 评论 -
Leetcode链表3
解法一:遍历求总长,再循环/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct ListNode* getKthFromEnd(struct ListNode *head, int k){ struct ListNode *p = head; int a = 1; while(p-.原创 2021-02-17 19:40:37 · 162 阅读 · 0 评论 -
Leedcode链表2
解法一:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */int getDecimalValue(struct ListNode* head){ int number=0; struct ListNode *p=head; while(p!=NULL) { numbe.原创 2021-02-17 17:45:00 · 94 阅读 · 0 评论 -
Leetcode链表1
这个题的思路很巧妙,要删除这个节点,那么就将该节点的下一个节点的值拿来赋给该节点,然后使用两个next跳过下一个节点即可,这样就达到了“删除”的效果。/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */void deleteNode(struct ListNode* node) { struct ListNode.原创 2021-02-17 17:00:41 · 93 阅读 · 0 评论