Easy
💻 Coding
[DevOps & Cloud] Valid Parentheses Check
Problem Statement
Problem Statement for Valid Parentheses Check under DevOps & Cloud:
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Input Constraints:
- 1 <= len(nums) <= 10^5
- Elements fit in memory standard spaces.
Proposed Solution
def isValid(s):
stack = []
mapping = {')': '(', '}': '{', ']': '['}
for char in s:
if char in mapping:
top = stack.pop() if stack else '#'
if mapping[char] != top:
return False
else:
stack.append(char)
return not stack
Your Progress
Pending Completion
Save Progress?
Login to sync your solutions across all dynamic local and remote sessions.
Join Techlance