```
public class Solution {
public int findNthDigit(int n) {
if(n > 0 && n < 10)
return n;
long[] num = new long[10];
num[0] = 1;
int i = 1;
for(;i < 10;i++){
num[i] = num[i - 1] + 9 * i * (long)Math.pow(10,i - 1);
if(n < num[i])
break;
}
int begain = 1;
for(int j = 1;j < i;j++){
begain *= 10;
}
long m = (n - num[i - 1])/i;
long k = i - 1 - (n - num[i - 1])%i;
long target = begain + m;
while(k != 0){
target /= 10;
k--;
}
return (int)(target % 10);
}
}
``
```