当前位置:网站首页>2022.6.11-----leetcode.926
2022.6.11-----leetcode.926
2022-06-12 08:31:00 【路Lu727】
public int minFlipsMonoIncr(String s) {
int n=s.length();
int[][] nums=new int[2][n+2];//记录某个字符前面1的个数,以及后面0的个数
for(int i=0,j=n-1;i<n&&j>=0;i++,j--){
nums[0][i+1]=nums[0][i];
if(s.charAt(i)=='1')
nums[0][i+1]++;
nums[1][j+1]=nums[1][j+2];
if(s.charAt(j)=='0')
nums[1][j+1]++;
}
int ans=100000;
for(int i=1;i<=n;i++){
ans=Math.min(ans,nums[0][i]+nums[1][i]-1);//找到最小次数
}
return ans;
}边栏推荐
- Install iptables services and open ports
- JVM learning notes: three local method interfaces and execution engines
- Principle and configuration of MPLS
- vm虛擬機中使用NAT模式特別說明
- What is the MES system? What is the operation process of MES system?
- Why should enterprises implement MES? What are the specific operating procedures?
- Production scheduling status of manufacturing enterprises and solutions of APS system
- 后MES系统的时代,已逐渐到来
- (p25-p26) three details of non range based for loop and range based for loop
- Configuration and principle of MSTP
猜你喜欢

Instructions spéciales pour l'utilisation du mode nat dans les machines virtuelles VM

Model Trick | CVPR 2022 Oral - Stochastic Backpropagation A Memory Efficient Strategy

Principle and configuration of MPLS

js中的正则表达式

Hands on deep learning -- weight decay and code implementation

Hands on deep learning -- Introduction to linear regression model
![[advanced pointer III] implement C language quick sorting function qsort & callback function](/img/f0/3729db83ba3eb15c7df0958858ece9.png)
[advanced pointer III] implement C language quick sorting function qsort & callback function

后MES系统的时代,已逐渐到来

Installation series of ROS system (I): installation steps

Hands on learning and deep learning -- a brief introduction to softmax regression
随机推荐
Centos8 installing MySQL 8.0 (upper)
深拷贝与浅拷贝的区别
How to write simple music program with MATLAB
动态创建表单并提交
What is the difference between ERP production management and MES management system?
记Date类型的一次踩坑
Calling stored procedures in mysql, definition of variables,
(P13) use of final keyword
js中的数组
How to understand the production scheduling of APS system?
js实现页面加载后再刷新一次
MES系统质量追溯功能,到底在追什么?
Installation of Shengxin R package
如何理解APS系统的生产排程?
(p15-p16) optimization of the right angle bracket of the template and the default template parameters of the function template
Hypergeometric cumulative distribution test overlap
企业上线MES软件的费用真的很贵?
【数据存储】浮点型数据在内存中的存储
Special notes on using NAT mode in VM virtual machine
JVM学习笔记:垃圾回收机制