标签:list next ext ndk public class find sig ret
/*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};*/
class Solution {
public:
ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) {
if(pListHead==NULL || k==0) return NULL;
ListNode *p=pListHead;
int length=0;
while(p->next!=NULL){
p=p->next;
length++;
}
if(k>length) return NULL;
ListNode *p1=pListHead;
ListNode *p2=pListHead;
for(int i=0;i<length-k;i++){
p1=p1->next;
}
while(p1->next!=NULL){
p1=p1->next;
p2=p2->next;
}
return p2;
}
};
标签:list next ext ndk public class find sig ret
原文地址:http://www.cnblogs.com/ymjyqsx/p/6107835.html