Skip to content

Commit 4e5b362

Browse files
committed
fix: posix lint 추가 및 house-robber 문제
1 parent 2198bdc commit 4e5b362

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

house-robber/ymir0804.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int rob(int[] nums) {
3+
int money = 0;
4+
for (int i = 0; i < nums.length; i++) {
5+
if (i % 2 == 0) {
6+
money += nums[i];
7+
}
8+
}
9+
return money;
10+
}
11+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import java.util.HashSet;
22

3-
class ymir0804 {
3+
class Solution {
44
public int longestConsecutive(int[] nums) {
55
HashSet<Integer> numsSet = new HashSet<>();
66
int maxNum = 0;
7-
for (int num: nums) {
7+
for (int num : nums) {
88
numsSet.add(num);
99
}
1010

11-
if(numsSet.isEmpty()) {
11+
if (numsSet.isEmpty()) {
1212
return 1;
1313
} else if (numsSet.size() == 1) {
1414
return 0;
1515
}
1616

17-
for (int num: numsSet) {
17+
for (int num : numsSet) {
1818
boolean isStartPoint = !numsSet.contains(num - 1);
1919
if (isStartPoint) {
2020
int current = num;
2121
int length = 1;
22-
while(numsSet.contains(++current)) {
22+
while (numsSet.contains(++current)) {
2323
length++;
2424
}
25-
if(length > maxNum) {
25+
if (length > maxNum) {
2626
maxNum = length;
2727
}
2828
}
2929
}
3030
return maxNum;
31-
}
32-
}
31+
}
32+
}

0 commit comments

Comments
 (0)