Maximum Score in Balanced String

Problem Overview

  • Determine the maximum score over any balanced substring of a parentheses string.
  • Input: string s with only '(' and ')'; Output: integer score j - i where s[i] = '(' and s[j] = ')' within the chosen balanced substring.
  • A balanced substring has equal counts of '(' and ')'; constraints not specified.
  • Domain: string parsing/validation; a common coding interview problem and interview question.
  • Asked in Amazon interviews.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: