코딩테스트/LeetCode
2022. 6. 24.
[LeetCode] Valid Parentheses
문제링크 Valid Parentheses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 주어진 괄호들이 올바른 괄호면 true, 아니면 false를 반환하는 문제이다. 접근 방법 stack개념을 사용하여 접근하였다. (First In Last Out) 1. 먼저 stack이 비었는데, 오른쪽 괄호가 나오면 false를 반환한다. if(stack.length === 0 && rightBasket.includes(s[i])) return false; 2. 왼쪽..