Skip to content

Commit 192ecf9

Browse files
authored
Merge pull request #1557 from AlgorithmWithGod/0224LJH
[20251201] PGM / LV2 / 올바른 괄호 / 이종환
2 parents 80373dc + c6d1c3e commit 192ecf9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
class Solution {
6+
boolean solution(String s) {
7+
boolean answer = true;
8+
char[] arr = s.toCharArray();
9+
int cur = 0;
10+
11+
for (int i = 0; i < arr.length; i++){
12+
cur += (arr[i] == '(')?1:-1;
13+
if (cur < 0 ) return false;
14+
}
15+
if (cur != 0) return false;
16+
17+
18+
return true;
19+
}
20+
}
21+
```

0 commit comments

Comments
 (0)