Solution to leetcode problem 856: Score of parentheses

In this Leetcode problem, we are given a balance parentheses string. That roughly means that each opening parenthesis is matched with exactly one closing parenthesis placed after the opening parenthesis. This way we won’t have illegal strings such as ()) or )(())(.

We are given a recursive definition of String score:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store