Invert a binary tree.
Trivia:
This problem was inspired by this original tweet by Max Howell:
Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so f*** off.
反轉一顆二元樹。
小知識:
這道題目發想自Max Howell的一篇推特:
Google:我們90%的工程師都在使用你寫的軟體(Homebrew),但是你不會在白板上寫出反轉二元樹所以滾出去。
(簡單來說,開發Homebrew的作者Max Howell以前曾應徵過google但沒過面試,後來在推特上發文諷刺白板題的重要性XD)
swap()
),然後遞迴呼叫左右子樹,直到自己是null
停止。LeetCode
C++