Kodebloc

Daily Coding Challenge

Solve today's challenge, earn streaks, and climb the leaderboard!

Share this challenge:
MEDIUM
Released: May 26, 2026 at 12:36 AM

Validate Parentheses String

Given a string containing only '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if open brackets must be closed by the same type of brackets, and open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type.

Problem Statement

Given a string `s` consisting of just the characters '(', ')', '{', '}', '[' and ']', write a function to determine if the input string is valid. The string `s` will have a length between 0 and 10^4. An empty string is considered valid. Your solution should return `true` if the string is valid, and `false` otherwise. Consider using a stack data structure for an efficient solution. The function `solution(s)` will receive the string directly as input.

Example Test Cases

Input:
s = "()"
Output:
"true"
Explanation:

The parentheses are correctly matched and ordered.

Input:
s = "()[]{}"
Output:
"true"
Explanation:

All bracket types are correctly matched and ordered.

Input:
s = "(]"
Output:
"false"
Explanation:

The open parenthesis '(' is closed by an incorrect type ']'. Incorrect match.

Sign in to save your progress and compete on the leaderboard

Leaderboard

Validate Parentheses String

No submissions yet for this filter

Be the first to solve this challenge!