public class Solution {
public List<String> summaryRanges(int[] nums) {
int i=0;
List<String> result=new ArrayList<String>();
while(i<nums.length){
int start =nums[i];
int end=nums[i];
while(i<nums.length-1&&nums[i]+1==nums[i+1]){
end++;
i++;
}
if(start==end){
result.add(start+"");
}else{
result.add(start+"->"+end);
}
i++;
}
return result;
}
}