```
class Solution {
public:
int findNthDigit(int n) {
int d = 1, base = 1;
while ((long long)9 * base * d - n < 0) {
n -= 9 * base * d++;
base *= 10;
}
int num = --n / d + base;
for (int i = 1; i < d - n % d; i++) num /= 10;
return num % 10;
}
};
```