```
/**
* Question 400 @LeetCode
*/
int findNthDigit(int n){
int digits = 1;
int ngc = 9;
int ngf = 1;
while(n > ngc && ngc > 0) {
n -= ngc;
ngf *= 10;
ngc = 9 * ngf * ++digits;
}
int number = ngf + (n - 1) / digits;
int offset = digits - 1 - (n - 1) % digits;
while(offset-- > 0) {
number /= 10;
}
return number % 10;
}
```