Last active
July 17, 2018 05:22
-
-
Save czcbangkai/f42db1754b6151e978617d934b27bd09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
╔════════════════╦══════════════════════════════════════════╦══════════════════════════════════════════╗ | |
║ 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 ║ ║ | |
║ Return Value ║ The final new root ║ The final new head ║ | |
╚════════════════╩══════════════════════════════════════════╩══════════════════════════════════════════╝ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment