Skip to content

Commit 01c3d00

Browse files
authored
Merge pull request #1908 from AlgorithmWithGod/ksinji
[20260208] PGM / LV3 / 풍선 터트리기 / 강신지
2 parents 61aa778 + 856fc3f commit 01c3d00

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
class Solution {
3+
public int solution(int[] a) {
4+
int answer = 0;
5+
6+
boolean[] survive = new boolean[a.length];
7+
8+
int left = Integer.MAX_VALUE;
9+
10+
for (int i=0; i<a.length; i++){
11+
if (left > a[i]){
12+
left = a[i];
13+
survive[i] = true;
14+
}
15+
}
16+
17+
int right = Integer.MAX_VALUE;
18+
19+
for (int i=a.length-1; i>=0; i--){
20+
if (right > a[i]){
21+
right = a[i];
22+
survive[i] = true;
23+
}
24+
}
25+
26+
for (int i=0; i<a.length; i++){
27+
if (survive[i]) answer++;
28+
}
29+
30+
return answer;
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)