Google | on site | Find minimum operations to flip an expression.
Anonymous User
2768

Given a string expresion, which only contains the following characters: '1', '0', '&', '|', '(', ')'.
For example, "1&(0|1)", the value of this expression is 1.
you can change '1 to '0',0 -> 1, & -> |, | -> &.
find the minimum operations to flip the value of the expression.
For example, "1&(0|1)", you can change the first '1' to '0', then the expresion becomes "0&(0|1)" and the value of this expression is 0.
I solved it with BFS, which cost o(2^len). len is the length of the string.
but the interviewer asked me to solve it with o(len) time.

Comments (6)