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 年 6 月 13 日
|
2
ryd994 2015 年 6 月 14 日 via Android
目前看见最好的就是强制cast指针,除了可移植性可能不太好之外
还有什么能比O(1)更快…… |
4
msg7086 2015 年 6 月 15 日
@kcworms 相当于交换对象方法的函数地址。
用ruby的话来说,就相当于 alias :temp, :left alias :left, :right alias :right, :temp 这样本来你访问n.left的时候,就变成调用Node::right()了。 估计只对动态语言有效? |