- Locate the number of digits
- Locate the number
- Locate the digit within the number

```
int findNthDigit(int n) {
long digit = 1, base = 9;
while (n - digit * base > 0) { // locate the number of digits
n -= digit * base;
digit++;
base *= 10;
}
string s = to_string(base / 9 + (n - 1) / digit); // locate the number
return s[(n - 1) % digit] - '0'; // locate the digit within the number
}
```