22.链表中倒数第k个节点
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* getKthFromEnd(struct ListNode* head, int k){
struct ListNode *fast=head,*slow=head;//双指针
int i;
for(i=0;i<k;i++)
fast=fast->next;
while(fast!=NULL)
{
slow=slow->next;
fast=fast->next;
}
return slow;
}