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 609e3c7 commit 5534d22Copy full SHA for 5534d22
1 file changed
two-sum/robinyoon-dev.js
@@ -0,0 +1,21 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @param {number} target
4
+ * @return {number[]}
5
+ */
6
+var twoSum = function (nums, target) {
7
+ for (let i = 0; i < nums.length; i++) {
8
+ let remaindedNum = target - nums[i];
9
+ let matchedNum = nums.find((item) => remaindedNum === item);
10
+ let matchedNumIndex = nums.indexOf(matchedNum, i + 1);
11
+ // i와 matchedNumIndex 이 같은 숫자면 안 됨.
12
+ if (i === matchedNumIndex) {
13
+ continue;
14
+ } else if (matchedNumIndex === -1) {
15
16
+ }
17
+ else {
18
+ return [i, matchedNumIndex];
19
20
21
+};
0 commit comments