lCOF-60
At first use recursion:
1 | var twoSum = function(n) { |
Unfortunetely, rum time error.
Refer to the official answer, we could use iterative method.
1 | var twoSum = function(n) { |
The time complexity is O(n2), and space complexity is O(n).
At first use recursion:
1 | var twoSum = function(n) { |
Unfortunetely, rum time error.
Refer to the official answer, we could use iterative method.
1 | var twoSum = function(n) { |
The time complexity is O(n2), and space complexity is O(n).