Problem 156: Binary Tree Upside Down
思路
观察上图,翻转的过程首先一路向左,找到“极左”的元素,这个点就是新的 tree 的 root。然后跟右边的元素连接并且断掉之前的元素的连接。
仔细观察上图可以发现,根的左左连根的右,根的左右连根本身。
Last updated
观察上图,翻转的过程首先一路向左,找到“极左”的元素,这个点就是新的 tree 的 root。然后跟右边的元素连接并且断掉之前的元素的连接。
仔细观察上图可以发现,根的左左连根的右,根的左右连根本身。
Last updated