| Topic | Difficulty | Companies |
|---|---|---|
| Stack and Queue | MEDIUM | Amazon Microsoft |
You are given a string s consisting of characters: (, ), [, ], { and }. Write a program to check whether the characters in the string s are valid or not.
Problem Note:
Example 1
Input: "(([](){}))"
Output: 1
Explanation: In the above example, every parenthesis and bracket has opening and closing in the correct order. Thus, we get 1(true) as output.
Example 2
Input: "([)]"
Output: 0
Explanation: In the above example, the brackets are closed but not in the correct order. Thus, we get 0(false) as output.
Example 3
Input: "()[]({})"
Output: 1
Explanation: In the above example, every parenthesis and bracket has opening and closing in the correct order. Thus, we get 1(true) as output.