>_
Compiler Shell v1.0.4
Connection to data node secure.
Parsed 600 algorithm challenges.
Mounted telemetry indexes.
> Launching prep command center...
Compiling 0%
Easy 💻 Coding

[Algorithms] Valid Parentheses Check

Problem Statement

Problem Statement for Valid Parentheses Check under Algorithms:

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
Back to Curriculum