Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 368 Bytes

代码片段.md

File metadata and controls

25 lines (19 loc) · 368 Bytes

代码片段

递归

递归求链表长度

private int length(ListNode head) { 
    if (head == null) 
        return 0; 
    return length(head.next) + 1; 
}

列表的逆序打印

public void printReverse(ListNode root){
    if (head == null) 
        return;
    printReverse(root.next);
    System.out.println(root.val);
}