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 26aa877 commit 0af9854Copy full SHA for 0af9854
two-sum/b41-41.ts
@@ -0,0 +1,27 @@
1
+// 1차 시도
2
+// function twoSum(nums: number[], target: number): number[] {
3
+// for(const index in nums) {
4
+// for(const index2 in nums) {
5
+// if (index !== index2) {
6
+// if(target === nums[index] + nums[index2]) {
7
+// return [Number(index), Number(index2)]
8
+// }
9
10
11
12
+// };
13
+
14
+// 2차 시도
15
+function twoSum(nums: number[], target: number): number[] {
16
+ for (const index in nums) {
17
+ for (let index2 = Number(index) + 1; index2 < nums.length; index2++) {
18
+ if(target === nums[index] + nums[index2]) {
19
+ return [Number(index), Number(index2)]
20
+ }
21
22
23
24
25
+ return [];
26
27
+};
0 commit comments