Skip to content

Commit 5229b02

Browse files
authored
Update missing-ranges.cpp
1 parent 927cacb commit 5229b02

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

C++/missing-ranges.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ class Solution {
55
public:
66
vector<string> findMissingRanges(vector<int>& nums, int lower, int upper) {
77
vector<string> ranges;
8-
for (int i = 0, pre = lower - 1, cur = 0; i <= nums.size(); ++i, pre = cur) {
8+
for (int64_t i = 0, pre = static_cast<int64_t>(lower) - 1, cur = 0; i <= nums.size(); ++i, pre = cur) {
99
if (i == nums.size()) {
10-
cur = upper + 1;
10+
cur = static_cast<int64_t>(upper) + 1;
1111
} else {
1212
cur = nums[i];
1313
}
@@ -18,6 +18,7 @@ class Solution {
1818
return ranges;
1919
}
2020

21+
private:
2122
string getRange(const int lower, const int upper) {
2223
if (lower == upper) {
2324
return to_string(lower);

0 commit comments

Comments
 (0)