/** * struct ListNode { * int val; * struct ListNode *next; * }; */ /** * * @param pListHead ListNode类 * @param k int整型 * @return ListNode类 */ struct ListNode* FindKthToTail(struct ListNode* pListHead, int k ) { if(pListHead == NULL||k == 0) { return NULL; } struct ListNode* fast = pListHead; struct ListNode* slow = pListHead; //保持K个距离走 int count= k-1; while(count--) { if(fast) fast = fast->next; } if(fast == NULL) { return NULL; } while(fast->next) { fast =fast->next; slow =slow->next; } return slow; }