Dsa
Stack
Warm-up
Valid Square Brackets
Write a function to determine if a string consisting of square brackets is valid. A string is considered valid if every opening bracket has a corresponding closing bracket and they are in the correct order.
Input Format:
A string made up of '[' and ']'.
Output Format:
Output 'true' if the string is valid, otherwise 'false'.
Example:
Input:
[[[]]]
Output:
true
Key concepts
stackstringvalidation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now