题解 | #链表中倒数最后k个结点#
链表中倒数最后k个结点
http://www.nowcoder.com/practice/886370fe658f41b498d40fb34ae76ff9
public ListNode FindKthToTail (ListNode h, int k) { // write code here if(list.size() < k || k == 0) return null; List<ListNode> list = new ArrayList<>(); while(h != null){ list.add(h); h = h.next; } if(list.size() == 0) return null; return list.get(list.size() - k); // 计算题目中要求的位置 }