FastPrepConfigurable Valid Brackets

Configurable Valid Brackets

Maven Clinic logoMaven Clinic● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW
Learn

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[]) → boolean

Examples

Example 1

text = "x<aAb>y"pairs = ["<>","aA","bB"]return = false

The closer b does not match the expected A.

Constraints

  • Every pair has length two.
  • Pair characters are globally distinct.
  • text.length <= 10^6.

More Maven Clinic problems

See Maven Clinic hiring insights
public boolean validConfiguredParentheses(String text, String[] pairs) {
  // Write your code here.
}
text"x<aAb>y"
pairs["<>","aA","bB"]
expectedfalse
Checking account…