Time Lapse :20min 50sec 1038.cpp12345678910111213141516171819202122232425262728293031323334353637#include <iostream>#include <list>#include <map>#include <unordered_map>using namespace std;unordered_map<int, list<long>> m;int N;long solution() { if(N <= 9) return N; N -= 9; int numberOfDigits = 2; while(numberOfDigits <= 10) { list<long> prevComb = m[numberOfDigits - 1]; list<long> curComb; for(auto num : prevComb) { int endOfDigit = num % 10; for(int i = 0; i < endOfDigit; i++) { curComb.push_back(num * 10 + i); N--; if(!N) return num * 10 + i; } } m[numberOfDigits++] = curComb; } return -1;}int main() { m[1] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; cin>>N; cout<<solution();}