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; } }
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; } }