class Solution {
public:
int findNthDigit(int n) {//数位n
long long start = 1;//每个digit起始的数字
int digit = 1;//位数
long long count = 9;//数位数量
while (n>count){
n -= count;
start *= 10;
digit++;
count = start* digit * 9;
}//这里做完定位到了n是几位数
int num = start + (n - 1) / digit;//定位到了是哪个数
string s = to_string(num);
return s[(n - 1) % digit] - '0';
}
};