1212. Sequential Digits
My accepted C++ solution to LeetCode problem 1212, Sequential Digits, running in 0ms.
- Difficulty: Medium
- C++
- Runtime 0ms
- Memory 8.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
C++
Accepted on LeetCode — runtime 0ms, memory 8.2MB, accepted 2025-12-27.
class Solution {
public:
vector<int> sequentialDigits(int low, int high) {
vector<int> result;
for (int len = 1; len <= 9; len++) {
for (int start = 1; start <= 10 - len; start++) {
int num = 0;
for (int i = 0; i < len; i++) num = num * 10 + (start + i);
if (num >= low && num <= high) result.push_back(num);
}
}
return result;
}
};