目录
代码部分:
核心:看图
代码部分:
struct ListNode* FindKthToTail(struct ListNode* pListHead, int k ) {// write code here// write code hereif (k == 0){return NULL;}else{struct ListNode* slow = pListHead, * fast = pListHead;//fast先走k步数while (k--){if (fast == NULL)return NULL;fast = fast->next;}//slow和fast一起走while (fast){fast = fast->next;slow = slow->next;}return slow;}}