Back to course home
0% completed
Vote For New Content
Solution: Minimum Suffix Flips
Problem Statement
You are given a target binary string of length n. Initially, you also have another string str of length n containing all 0s. You need to make str equal to the target by performing some number of operations.
In one operation, you can take an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Here, Flip means changing '1' to '0' and '0' to '1'.
Return the minimum number of operations required to make string str equal to target.
Examples
- Example 1:
- Input: target =
"001"
- Input: target =
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page