点击打开链接
//从1开始到第n个数字
class Solution {
public:
int findNthDigit(int n) {
long digit = 1;
long base = 9;
long ith =1;
while (n> base*digit) {
n-=base *digit;
digit+=1;
ith += base;
base = base*10;
}
return to_string(ith+(n-1)/digit)[(n-1)%digit]-'0';//表示string下标的哪一位
}
};