We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03140c1 commit dabb24dCopy full SHA for dabb24d
two-sum/byol-han.js
@@ -0,0 +1,22 @@
1
+// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
2
+
3
+// You may assume that each input would have exactly one solution, and you may not use the same element twice.
4
5
+// You can return the answer in any order.
6
7
+/**
8
+ * @param {number[]} nums
9
+ * @param {number} target
10
+ * @return {number[]}
11
+ */
12
+var twoSum = function (nums, target) {
13
+ let result = [];
14
+ for (let i = 0; i < nums.length; i++) {
15
+ for (let j = i + 1; j < nums.length; j++) {
16
+ if (nums[i] + nums[j] === target) {
17
+ return [i, j];
18
+ }
19
20
21
+ return result;
22
+};
0 commit comments