질문&답변
런타임 에러이유가 멀까요?
EmptyStackExecption 에 대한 try-catch 구현하시면 됩니다 class Solution { public String solution(String str) { Stack stack = new Stack (); try { str.chars().mapToObj(i -> (char) i).forEachOrdered(c -> { if (c == '(') stack.push(c); else if (c == ')') stack.pop(); }); } catch(EmptyStackException e){ return "NO"; } return (stack.isEmpty()) ? "YES" : "NO"; } }
- 좋아요수
- 0
- 댓글수
- 2
- 조회수
- 409





