bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumStackLC 856

Score of Parentheses

Given a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "() " has score 1. AB has score A + B, where A and B are balanced parentheses strings. (A) has score 2 A, where A is a balanced parentheses string.

Asked at 3 companies
AdobeAmazonBytedance
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode