Description
One of the approved questions we have was recently asked by Google, and it is this:
You need to check whether the string is well nested or not based on two conditions:
- If they are, return the string as-is.
- If they are not, repair the string so that the parentheses are well nested and return the result.
You can perform three actions to validate the string. Three actions are: Delete, Add, Update.
You must convert it a well-nested string with the minimum number of actions.
Test Examples:
Input: (()
Output: (()), or () or ()()
Input: (())))
Output: ((()))
It'll be good to have a solution for this so we can display it on the website, and so we can make a video out of it.