Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.