Search
⌘K

Leetcode 1541. Minimum Insertions to Balance a Parentheses String

Given a string of '(' and ')', return the minimum number of insertions needed to make it balanced under the rule that each '(' must be closed by two consecutive ')' (i.e., treat '))' as one closing), with insertions allowed anywhere. This is a linear-time greedy/stack-style balance problem (n up to 1e5).

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early March, 2025

Meta

Staff

Asked on my screening interview; as is

Late January, 2025

Meta

Mid-level

Late January, 2025

Meta

Staff

Comments

Your account is free and you can post anonymously if you choose.