typedef struct ListNode{
int data;
struct ListNode* next;
}ListNode;
ListNode* FindKthToTail(ListNode* pListHead, uint32 k){
if(pListHead== nullptr){
return nullptr;
}
ListNode* pA=pListHead;
ListNode* pB=pListHead;
for(int i=0;i<k-1;i++){
if(pB->next!=nullptr){
pB=pB->next;
} else{
return nullptr;
}
}
while(pB->next!= nullptr){
pB=pB->next;
pA=pA->next;
}
cout<<"111"<<endl;
return pA;
}
求链表导数第k个节点
最新推荐文章于 2022-06-12 01:14:10 发布