Minimum Add to Make Parentheses Valid
Google Interview Question
Problem Overview
Difficulty: Medium
LeetCode Pattern: Stack
You are given a string s containing only ( and ). In one move, you can insert a parenthesis anywhere. Return the minimum number of insertions needed to make s valid.
Note: A string of parentheses is valid if:
It is empty.
Or it can be formed by:
concatenating two valid strings.
Or it is wrapped like:
(A…
Keep reading with a 7-day free trial
Subscribe to Harpreet's Newsletter to keep reading this post and get 7 days of free access to the full post archives.

