/* public class ListNode { int val; ListNode next = null;
ListNode(int val) { this.val = val; } }*/ public class Solution { public ListNode FindKthToTail(ListNode head,int k) { if (k <= 0) { return null; } ListNode refrence = head; ListNode point = null; int i = 1; while (null != refrence) { if (i == k) { point = head; } else if (i > k){ point = point.next; } refrence = refrence.next; i++; } return point; } }
近期评论