寻找链表中倒数第k个节点
public ListNode getKthFromEnd(ListNode head, int k) { ListNode slow=head; ListNode fast=head; int t = 0; for(;fast!=null;){ if(t>=k) { slow=slow.next; } fast = fast.next; t++; } return slow; }
public ListNode getKthFromEnd(ListNode head, int k) { ListNode slow=head; ListNode fast=head; int t = 0; for(;fast!=null;){ if(t>=k) { slow=slow.next; } fast = fast.next; t++; } return slow; }