File tree 2 files changed +42
-1
lines changed
2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 35
35
7 . [ Asteroid Collision] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3502/ ) ➡️ [ CPP Solution] ( Week3/asteroidCollision.cpp )
36
36
37
37
38
- ## Week 4 🚧
38
+ ## Week 4 ✅
39
39
40
40
1 . [ Minimum Depth of Binary Tree] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3504/ ) ➡️ [ CPP Solution] ( Week4/minDepth.cpp )
41
41
2 . [ 132 Pattern] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3505/ ) ➡️ [ CPP Solution] ( Week4/find132pattern.cpp )
42
42
3 . [ Bag of Tokens] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3506/ ) ➡️ [ CPP Solution] ( Week4/bagOfTokensScore.cpp )
43
43
4 . [ Stone Game IV] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3507/ ) ➡️ [ CPP Solution] ( Week4/winnerSquareGame.cpp )
44
44
5 . [ Champagne Tower] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3508/ ) ➡️ [ CPP Solution] ( Week4/champagneTower.cpp )
45
45
6 . [ Linked List Cycle II] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3509/ ) ➡️ [ CPP Solution] ( Week4/detectCycle.cpp )
46
+ 7 . [ Summary Ranges] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3510/ ) ➡️ [ CPP Solution] ( Week4/summaryRanges.cpp )
46
47
47
48
## Week 5 🚧
48
49
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ vector<string> summaryRanges (vector<int >& nums) {
4
+ int n = nums.size ();
5
+ vector<string> result;
6
+
7
+ if (n == 0 ) return result;
8
+
9
+ int start = nums[0 ], end = nums[0 ];
10
+ string val;
11
+
12
+ for (int i = 1 ; i < n; ++i) {
13
+ if (end + 1 == nums[i]) {
14
+ end = nums[i];
15
+ continue ;
16
+ }
17
+
18
+ if (start == end) {
19
+ val = to_string (start);
20
+ result.push_back (val);
21
+ } else {
22
+ val = to_string (start) + " ->" + to_string (end);
23
+ result.push_back (val);
24
+ }
25
+
26
+ start = nums[i];
27
+ end = nums[i];
28
+ }
29
+
30
+ if (start == end) {
31
+ val = to_string (start);
32
+ result.push_back (val);
33
+ } else {
34
+ val = to_string (start) + " ->" + to_string (end);
35
+ result.push_back (val);
36
+ }
37
+
38
+ return result;
39
+ }
40
+ };
You can’t perform that action at this time.
0 commit comments