Leetcode 1896. Minimum Cost to Change the Final Value of Expression
Given a parenthesized boolean expression evaluated left-to-right (no operator precedence), compute the minimum number of single-character flips (change a literal 0↔1 or an operator &↔|) needed to make the whole expression evaluate to the opposite value. The core challenge is to parse the expression into subexpressions and use DP on the expression tree/stack to track the minimal cost to force each subtree to 0 or 1 (must handle up to 1e5 length efficiently).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.