leetcode地址,java版代码:
1 class Solution { 2 public int findNthDigit(int n) { 3 int digit = 1; 4 long start = 1; 5 long count = 9; 6 while (n > count) { // 1. 7 n -= count; 8 digit += 1; 9 start *= 10; 10 count = digit * start * 9; 11 } 12 long num = start + (n - 1) / digit; // 2. 13 return Long.toString(num).charAt((n - 1) % digit) - '0'; // 3. 14 } 15 }