← 返回 nvidia 的题目列表Verify Matching Brackets in a Mathematical Expression
类型:online_judge
Implement a function to verify whether brackets in a mathematical expression are properly matched.
Rules:
The string s contains digits/letters/spaces/operators + - * / ^ and brackets ()[]{}.
Brackets must be paired, type-matching, and properly nested (e.g., ([)] is invalid).
Ignore all non-bracket characters.
Input (stdin): one line string s Output (stdout): true or false Constraints: 1 <= len(s) <= 2e5.
Example
Input
(1 + 2) * [3 + {4/2}]
Output
true