Microsoft Interview Question: Valid Parentheses Checker

Valid Parentheses Checker
Given a string s containing only '(' , ')' , '{' , '}' , '[' , ']', return True if valid: opens must be closed by same type and in correct order.

Test Cases

  1. "()" → True
  2. "[]{}" → True
  3. "[" → False
  4. "({})" → True
  5. "(((((((())))))))" → True
  6. "([)]" → False
  7. "]" → False
  8. "" → True
  9. "(((" → False
  10. "())" → False

Classic stack validation: push opening brackets, on closing bracket check top matches type, otherwise invalid; finally stack must be empty. Edge cases: empty string is valid, premature closing, leftover opens. Complexity is linear time and linear space in worst case.

END
 0