Stack2 [Leetcode][Javascript][Easy] 155. Min Stack https://leetcode.com/problems/min-stack/ Min Stack - 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 /** * initialize your data structure here. */ var MinStack = function() { this._value = []; this._sortedValue = []; }; /** * @param {number} val * @return {void} */ MinStack.prototy.. 2021. 6. 30. [Leetcode][Javascript][Easy] 20. Valid Parentheses /** * @param {string} s * @return {boolean} */ var isValid = function(s) { var stack = new Stack(); for (let i = 0; i < s.length; i++) { if (s[i] === '(' || s[i] === '[' || s[i] === '{') { stack.push(s[i]); } if (s[i] === ')') { if (stack.pop() !== '(') { return false; } } else if (s[i] === ']') { if (stack.pop() !== '[') { return false; } } else if (s[i] === '}') { if (stack.pop() !== '{') { re.. 2021. 6. 28. 이전 1 다음