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 0fc7ec8 commit 25f0b86Copy full SHA for 25f0b86
1 file changed
two-sum/dev-qorh.ts
@@ -0,0 +1,20 @@
1
+/**
2
+ * 가장 단순한 O(n^2) 로 풀이하였습니다
3
+ */
4
+function twoSum(nums: number[], target: number): number[] {
5
+ let temp_i = 0;
6
+ let temp_j = 0;
7
+
8
+ for (let i = 0; i < nums.length; i++) {
9
+ temp_i = nums[i];
10
+ for (let j = i + 1; j < nums.length; j++) {
11
+ temp_j = nums[j];
12
13
+ if (temp_i + temp_j === target) {
14
+ return [i, j];
15
+ }
16
17
18
19
+ return [];
20
+}
0 commit comments