AmazonOA #387
Maximum Score in Balanced String
估计中等评测数据准备中,可先阅读题面
Given a string s consisting of parentheses, you need to find the maximum score possible in a balanced substring of s. The score of a substring is calculated by choosing two indices i and `j (0 Note
The input string s will only consist of opening and closing parentheses. A balanced substring is a substring that has an equal number of opening and closing parentheses.
Constraints
N/A (feel free to contact us if you know about it. TYSM!
Example 1
Input:
s = "(())"
Output:
4
Explanation: There are two possible balanced substrings: "( ( ) )" (3-0) + (2-1) = 4 or (2-0) + (3-1) = 4
Example 2
Input:
s = "()()"
Output:
3
Explanation: We dont need to use the two parenthesis in the middle :) Updated on 02-04-2025, relative image will be uploaded next time :P