标签:nod class image efi inf 描述 next i++ val
题目描述:
java:快慢指针:
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode getKthFromEnd(ListNode head, int k) { ListNode former = head,latter = head; for(int i = 0;i<k;i++) former = former.next; while(former!=null){ former = former.next; latter = latter.next; } return latter; } }
标签:nod class image efi inf 描述 next i++ val
原文地址:https://www.cnblogs.com/oldby/p/12709653.html