# LEETCODE--Summary Ranges

Given a sorted integer array without duplicates, return the summary of its ranges.

For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].

class Solution {
public:
char buffer[30];
if(end == begin)
sprintf(buffer,"%d",end);
else
sprintf(buffer,"%d->%d",begin, end);
return string(buffer);
}
vector<string> summaryRanges(vector<int>& nums) {
vector<string> finsh;
int len = nums.size();
if(len == 0)
return finsh;
int end = nums[0];
int begin = nums[0];
for(int i = 1; i < len; i++){
if(end == nums[i] || (end + 1) == nums[i])
end = nums[i];
else{
finsh.push_back(next);
begin = nums[i];
end = nums[i];
}
}
finsh.push_back(next);
}
};

class Solution {
public:
string s;
if(begin == end)
s = to_string(end);
else{
s = to_string(begin) + "->";
s += to_string(end);
}
return s;
}
vector<string> summaryRanges(vector<int>& nums) {
vector<string> finsh;
int len = nums.size();
if(len == 0)
return finsh;
int end = nums[0];
int begin = nums[0];
for(int i = 1; i < len; i++){
if(end == nums[i] || (end + 1) == nums[i])
end = nums[i];
else{
finsh.push_back(next);
begin = nums[i];
end = nums[i];
}
}
finsh.push_back(next);
}
};

class Solution {
public:
string s;
string s1;
if(begin == end){
stringstream ss;
ss << end;
ss >> s1;
s = s1;
}
else{
stringstream ss;
ss << begin;
ss >> s1;
ss.clear();
s += s1;
s +='-';
s +='>';
ss << end;
ss >> s1;
s += s1;
}
return s;
}
vector<string> summaryRanges(vector<int>& nums) {
vector<string> finsh;
int len = nums.size();
if(len == 0)
return finsh;
int end = nums[0];
int begin = nums[0];
for(int i = 1; i < len; i++){
if(end == nums[i] || (end + 1) == nums[i])
end = nums[i];
else{
};