인프런 커뮤니티 질문&답변
테스트 케이스를 추가해야 할 거 같아요
해결된 질문
작성
·
391
0
채점사이트에서 해당 문제의 테스트 케이스 중에서 여는 괄호가 많은 케이스를 추가해야 할 거 같아요!
for문이 끝나고 stack이 비어있는 것을 체크 안하고 "YES"를 반환하도록 코드를 작성했는데 통과합니다!
테스트 케이스를 통과한 코드는 다음과 같아요
private static String solutionUseStack(final String parenthesis){
final Stack<Character> leftParenthesis = new Stack<>();
for (char c : parenthesis.toCharArray()){
if(c == '(')
leftParenthesis.push('(');
else{
if(leftParenthesis.empty())
return "NO";
else
leftParenthesis.pop();
}
}
return "YES";
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final String parenthesis = sc.next();
// System.out.println(solution(parenthesis));
System.out.println(solutionUseStack(parenthesis));
}퀴즈
스택(Stack)과 큐(Queue) 자료구조의 데이터를 처리하는 가장 큰 차이점은 무엇일까요?
데이터 저장 용량
데이터가 들어오고 나가는 순서
사용 가능한 연산의 종류
메모리 할당 방식





