
【解题思路】


class Solution {
public int findNthDigit(int n) {
int d = 1, count = 9;
while (n > (long) d * count) {
n -= d * count;
d++;
count *= 10;
}
int index = n - 1;
int start = (int) Math.pow(10, d - 1);
int num = start + index / d;
int digitIndex = index % d;
int digit = (num / (int)(Math.pow(10, d - digitIndex - 1))) % 10;
return digit;
}
}
本文详细阐述了如何通过算法计算给定整数序列中的第N位数字,包括解题思路和实现过程。
1227

被折叠的 条评论
为什么被折叠?



