[JS]链表倒数第k个节点
链表中倒数第k个结点
http://www.nowcoder.com/questionTerminal/529d3ae5a407492994ad2a246518148a
常规解法,快指针向前遍历k个
function FindKthToTail(head, k) { // write code here let fast = head let i=0 for(;i<k&&fast;i++){ fast = fast.next } if(!fast&&i<k){ return //k比链表的长度还大 } while(fast){ head = head.next fast = fast.next } return head }