Skip to content

Commit 4d49d49

Browse files
committed
Valid Parentheses - s의 길이가 홀수인 경우 early return
1 parent f848beb commit 4d49d49

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

valid-parentheses/forest000014.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class Solution {
99
public boolean isValid(String s) {
1010
Stack<Character> st = new Stack<>();
1111

12+
if (s.length() % 2 == 1) {
13+
return false;
14+
}
15+
1216
for (char ch : s.toCharArray()) {
1317
if (ch == '(' || ch == '{' || ch == '[') {
1418
st.push(ch);

0 commit comments

Comments
 (0)