A+B...不会溢出么?
sooner0493 opened this issue · comments
(Integer.MAX_VALUE,100)
Good point. 我觉得问到这个问题的时候, 可以提出来,要不要用一个long to catch the final result.
一开始来一个 long result = a, 然后把接下去代码里面的a都写成result就行了吧. (https://github.com/shawnfan/LintCode/blob/master/Java/A+B.java)
如果大家都assume 不会溢出, 那就这么用a 作为结果。
我也是这么改的。。