新浪----查找单链表中的倒数第K个节点
思路分析:遍历整个链表,得到链表的总长度size,接着再次遍历(size-k)个即可。
public static Node findNode(Node head,int k){
if(head.next==null){
return null;
}
int size=getLength(head);//调用getLength()方法获取链表长度
if(k<=0||k>size){
return null;
}
//定义辅助变量cur
Node cur=head.next;
for(int i=