#228. Summary Ranges 题目链接
public class Solution {
public ArrayList<String> summaryRanges(int[] nums) {
ArrayList<String> list = new ArrayList<String>();
int start = 0, end = 0;
if(nums.length != 0)
start = end = nums[0];
int i = 0;
while (i < nums.length) {
start = nums[i];
while(++i < nums.length){
if(nums[i] - nums[i-1] == 1){
end = nums[i];
continue;
}
else {
end = nums[i - 1];
break;
}
}
if (start != end) {
String a = start+"->"+end;
list.add(a);
} else {
String a = String.valueOf(start);
list.add(a);
}
if (i < nums.length) {
start = end = nums[i];
}
}
return list;
}
}