We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70e043e commit 949bef5Copy full SHA for 949bef5
summary-ranges.cpp
@@ -0,0 +1,25 @@
1
+//Runtime: 0 ms
2
+class Solution {
3
+public:
4
+ vector<string> summaryRanges(vector<int>& nums) {
5
+ string t;
6
+ vector<string>temp;
7
+
8
+ for(int i=0;i<nums.size();i++)
9
+ {
10
+ t = to_string(nums[i]);
11
+ int ti = i;
12
+ while(i+1<nums.size() && nums[i] == nums[i+1]-1)
13
+ i++;
14
15
+ if(ti != i)
16
17
+ t += "->";
18
+ t += to_string(nums[i]);
19
+ }
20
21
+ temp.push_back(t);
22
23
+ return temp;
24
25
+};
0 commit comments