Skip to content

Commit c86b201

Browse files
committed
파일의 마지막에 개행문자를 추가
1 parent 659e802 commit c86b201

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

house-robber/dohyeon2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ public int rob(int[] nums) {
2727

2828
return dp[nums.length - 1];
2929
}
30-
}
30+
}

longest-consecutive-sequence/dohyeon2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ public int longestConsecutive(int[] nums) {
7676

7777
return count;
7878
}
79-
}
79+
}

top-k-frequent-elements/dohyeon2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public int[] topKFrequent(int[] nums, int k) {
4444

4545
return result;
4646
}
47-
}
47+
}

two-sum/dohyeon2.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22

33
class Solution {
44
public int[] twoSum(int[] nums, int target) {
5-
// Approach : using HashMap to get index with the element in O(n) time complexity
5+
// Approach : using HashMap to get index with the element in O(n) time
6+
// complexity
67
// SpaceComplexity is also O(n)
7-
HashMap<Integer,Integer> numIndexMap = new HashMap<Integer,Integer>();
8+
HashMap<Integer, Integer> numIndexMap = new HashMap<Integer, Integer>();
89

910
// Make key and value HashMap
10-
for(int i = 0; i < nums.length; i++){
11+
for (int i = 0; i < nums.length; i++) {
1112
int num = nums[i];
12-
numIndexMap.put(num,i);
13+
numIndexMap.put(num, i);
1314
}
1415

1516
// Search for the other operand looping nums
16-
for(int i = 0; i < nums.length; i++){
17+
for (int i = 0; i < nums.length; i++) {
1718
int num = nums[i];
1819
int operand = target - num;
1920
Integer index = numIndexMap.get(operand);
2021
boolean indexExists = index != null;
2122
boolean indexExistsAndIndexIsNotTheNum = indexExists && i != index;
22-
if(indexExistsAndIndexIsNotTheNum){
23+
if (indexExistsAndIndexIsNotTheNum) {
2324
// Manual sort
24-
if( i < index){
25-
return new int[]{ i, index };
26-
}else{
27-
return new int[]{ index, i };
25+
if (i < index) {
26+
return new int[] { i, index };
27+
} else {
28+
return new int[] { index, i };
2829
}
2930
}
3031
}
@@ -33,4 +34,4 @@ public int[] twoSum(int[] nums, int target) {
3334
// But the compiler don't know about that
3435
return new int[2];
3536
}
36-
}
37+
}

0 commit comments

Comments
 (0)