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 b2ed5eb commit 6b77a25Copy full SHA for 6b77a25
suyeun84/202509/23 PGM LV3 풍선 터트리기.md
@@ -0,0 +1,30 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int solution(int[] a) {
5
+ int answer = 0;
6
+ int n = a.length;
7
+ if (n == 1) return 1;
8
+ int[] left = new int[n];
9
+ int[] right = new int[n];
10
+
11
+ left[0] = a[0];
12
+ for (int i = 1; i < n; i++) {
13
+ left[i] = Math.min(left[i - 1], a[i]);
14
+ }
15
16
+ right[n - 1] = a[n - 1];
17
+ for (int i = n - 2; i >= 0; i--) {
18
+ right[i] = Math.min(right[i + 1], a[i]);
19
20
+ for (int i = 0; i < n; i++) {
21
+ if (i == 0 || i == n-1) answer++;
22
+ else {
23
+ if (left[i-1] < a[i] && right[i+1] < a[i]) continue;
24
+ answer++;
25
26
27
+ return answer;
28
29
+}
30
+```
0 commit comments