You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.

In one operation, you can pick an index i where 0 &lt;= i &lt; n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.

Return the minimum number of operations needed to make s equal to target.

&nbsp;
Example 1:

Input: target = "10111"
Output: 3
Explanation: Initially, s = "00000".
Choose index i = 2: "00000" -&gt; "00111"
Choose index i = 0: "00111" -&gt; "11000"
Choose index i = 1: "11000" -&gt; "10111"
We need at least 3 flip operations to form target.


Example 2:

Input: target = "101"
Output: 3
Explanation: Initially, s = "000".
Choose index i = 0: "000" -&gt; "111"
Choose index i = 1: "111" -&gt; "100"
Choose index i = 2: "100" -&gt; "101"
We need at least 3 flip operations to form target.


Example 3:

Input: target = "00000"
Output: 0
Explanation: We do not need any operations since the initial s already equals target.


&nbsp;
Constraints:


	n == target.length
	1 &lt;= n &lt;= 105
	target[i] is either '0' or '1'.


class Solution:
    def minFlips(self, target: str) -> int:
        flip = False
        res = 0
        for c in target:
            if (c == '1') != flip:
                flip = not flip
                res += 1
        
        return res
class Solution {
    public int minFlips(String target) {

        boolean lastBit = false;

        int flips = 0;
        for(int i=0;i<target.length();i++){

            if(target.charAt(i)=='1' && !lastBit){
                flips++;
                lastBit = !lastBit;
            }
            else if(target.charAt(i)=='0' && lastBit){
                flips++;
                lastBit = !lastBit;
            }

        }

        return flips;

    }
}
class Solution {
public:
    int minFlips(string target) {
	int count=0;
		// we see thye number of times the change occur
        for(int i=0; i<target.size()-1;i++){
            if(target[i] != target[i+1] ){
                count++;
            }}
        if(target[0]=='0'){return count;}
        else{return count+1;}
        return 0;
    }
};
var minFlips = function(target) {
    target = "0" + target;
    let count = (target.match(/01/g) || []).length * 2;
    return target[target.length -1] ==="0" ? count : count - 1;
};
Minimum Suffix Flips