/**
* @author xnl
* @Description:
* @date: 2022/7/16 22:38
*/
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
}
public int minFlips(String target) {
int res = 0;
char pre = '0';
for (int i = 0; i < target.length(); i++){
char cur = target.charAt(i);
if (cur != pre){
res++;
pre = cur;
}
}
return res;
}
}
使用贪心