Implement solve(str) that returns true when every opening bracket instr is closed by the correct matching bracket in the correct order, andfalse otherwise.
Supported pairs: () [] {}
Non-bracket characters are ignored.
Examples
solve("({[]})") → true
solve("()[]{}") → true
solve("([)]") → false // interleaved — wrong order
solve("{[]") → false // unclosed opening
solve("") → true // empty string is balancedApproach
Use a stack: push each opening bracket; on a closing bracket, pop and verify
the match. Return true only if the stack is empty at the end.
Constraints
()[]{} matter.([)].Sample tests