Skip to content

Instantly share code, notes, and snippets.

View czcbangkai's full-sized avatar

Jim Chen czcbangkai

View GitHub Profile
╔════════════════╦══════════════════════════════════════════╦══════════════════════════════════════════╗
║ Logic ║ Flip Binary Tree ║ Reverse Singly Linked List ║
╠════════════════╬══════════════════════════════════════════╬══════════════════════════════════════════╣
║ Base Case ║ Root is empty ║ Head is empty ║
║ ║ Root has no left child ║ Head has no next node ║
║ Recursive Call ║ Call root.left to get the final new root ║ Call head.next to get the final new head ║
║ Current Call ║ Let root.left.right point to root ║ Let head.next.next point to head ║
║ ║ Let root.left.left point to root.right ║ ║
║ ║ Let root.left point to NULL ║ Let head.next point to NULL ║
║ ║ Let root.right point to NULL ║