这题不Easy呀,像智力题,像脑筋急转弯。
代码是人家的,我可想不出来。真是“会者不难,难者不会”。
- How do I add two numbers without using any operator C/C++?
- What is the best way to add two numbers without using the + operator?
- Add two numbers without using arithmetic operators
JavaScript
自增自减运算符
1 | /** |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 3.38 % of javascript submissions.
位运算+递归
1 | /** |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 69.57 % of javascript submissions
消除递归的位运算
知其然而不知其所以然,居然可以这么做,觉得很神奇
1 | /** |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 100.00 % of javascript submissions.
Java
消除递归的位运算
1 | class Solution { |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 100.00 % of java submissions.
递归+位运算
1 | class Solution { |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 100.00 % of java submissions.
自增自减运算符
这个解很像脑筋急转弯,不难,但让人想不到
1 | class Solution { |
Submission Detail
- 13 / 13 test cases passed.
- Your runtime beats 3.44 % of java submissions.