/** * struct ListNode { * int val; * struct ListNode *next; * }; */ /** * * @param pListHead ListNode类 * @param k int整型 * @return ListNode类 */ struct ListNode* FindKthToTail(struct ListNode* pListHead, int k ) { // write code here if(pListHead==NULL)return NULL; struct ListNode* slow=pListHead; struct ListNode* fast=pListHead; if(k<=0)return NULL; while(k>1) { k--; if(fast) fast=fast->next; else fast=NULL; } if(!fast)return NULL; while(fast->next) { slow=slow->next; fast=fast->next; } return slow; }