https://leetcode.com/problems/invert-binary-tree/
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 fuck off.
这题还是easy的哦WWWWW
1
101 2015-06-13 17:44:45 +08:00
|
2
ryd994 2015-06-14 09:50:46 +08:00 via Android
目前看见最好的就是强制cast指针,除了可移植性可能不太好之外
还有什么能比O(1)更快…… |
4
msg7086 2015-06-15 00:32:20 +08:00
@kcworms 相当于交换对象方法的函数地址。
用ruby的话来说,就相当于 alias :temp, :left alias :left, :right alias :right, :temp 这样本来你访问n.left的时候,就变成调用Node::right()了。 估计只对动态语言有效? |