Valid Parentheses
Easy
Stack
GoogleAmazonMicrosoft
Given a string of just '()[]{}', decide if the brackets are balanced and correctly nested.
Input: one line.
Output: "true" or "false".
Input: one line.
Output: "true" or "false".
Examples
Input:
()[]{}
Output:
true
Input:
(]
Output:
false
Constraints
1 <= length <= 10^4
Sample test cases
Input
()[]{}
Expected output
true
Input
(]
Expected output
false
Try solving it yourself first 💪
Write your solution in the editor, then hit “Mark solved”. In-browser run & auto-check is coming soon.