Configurable Valid Parentheses
Problem statement
Each two-character string in pairs gives an opening and its matching closing character. Ignore text characters absent from all pairs. Return true when configured delimiters are correctly nested and completely closed.
Function
validConfiguredParentheses(text: String, pairs: String[]) → booleanExamples
Example 1
text = "x<aAb>y"pairs = ["<>","aA","bB"]return = falseThe closer b does not match the expected A.
Constraints
- Every pair has length two.
- Pair characters are globally distinct.
text.length <= 10^6.