public class Solution {
public ListNode FindKthToTail(ListNode head, int k) {
ListNode res = head;
int index = 0;
while(head != null){
if(index == k){
res = res.next;
}
else{
index++;
}
head = head.next;
}
if(index < k)
return null;
return res;
}
}
京公网安备 11010502036488号