763. Partition Labels
2018-01-18 14:23
141 查看
内容:
A string
思路:
从一开始那些key point就定下来了,只要往下走下去就好了,一步步往后推
public static int removeDuplicates(int[] nums) {
if(nums.length<2){
return nums.length;
}
int temp=nums[0];
int insert=1;
boolean gate=false;
for(int i=1;i<nums.length;i++){
if(nums[i]==temp){
if(gate){
continue;
}else{
gate=true;
nums[insert++]=temp;
}
}else{
gate=false;
nums[insert++]=nums[i];
temp=nums[i];
}
}
if(insert<nums.length){
nums[insert]=nums[insert-1]+1;
}
return insert;
}
A string
Sof lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.
思路:
从一开始那些key point就定下来了,只要往下走下去就好了,一步步往后推
public static int removeDuplicates(int[] nums) {
if(nums.length<2){
return nums.length;
}
int temp=nums[0];
int insert=1;
boolean gate=false;
for(int i=1;i<nums.length;i++){
if(nums[i]==temp){
if(gate){
continue;
}else{
gate=true;
nums[insert++]=temp;
}
}else{
gate=false;
nums[insert++]=nums[i];
temp=nums[i];
}
}
if(insert<nums.length){
nums[insert]=nums[insert-1]+1;
}
return insert;
}
相关文章推荐
- UVA 763 Fibinary Numbers
- UVA 763 - Fibinary Numbers(高精度斐波那契 + 高精度模板)
- TwoPointers-763-Partition Labels
- 2012-11-7 11gR2 "ADMINISTRATOR'S GUIDE" page 763 - 808
- [Swust OJ 763]--校门外的树 Plus(暴力枚举)
- Codeforces 763 A. Timofey and a tree (dfs)
- UVa 763 - Fibinary Numbers
- CDOJ 763 树上的鸟儿(水题/模拟题)
- (server.c.763) can't find username lighttpd
- nyoj Vawio Sequence 763 (STL) LIS变型
- UVA - 763 Fibinary Numbers
- Vawio Sequence (NYOJ 763 LIS变形)
- uva 763 - Fibinary Numbers(斐波那契数)
- idea报错:[2016-08-31 09:20:10,763] Artifact xxx:war exploded: Error during artifact deployment.
- UVA 763 - Fibinary Numbers(高精度斐波那契)
- idea报错:[2016-08-31 09:20:10,763] Artifact xxx:war exploded: Error during artifact deployment.
- uva 763 - Fibinary Numbers(Fibonacci)
- codeforces 763 C Timofey and remoduling(数学)
- uva 763 Fibinary Numbers
- uva 763 Fibinary Numbers