LeetCode—400. Nth Digit
2016-09-21 10:00
295 查看
Nth Digit思路:先找出这是第哪个数,然后确定是这个数的第几位,观察可得,一位数有9个,1-9,二位数有90个,10-99,三位数有900个,100-999,以此类推
GitHub地址:https://github.com/corpsepiges/leetcode
点此进入如果可以的话,请点一下star,谢谢。
GitHub地址:https://github.com/corpsepiges/leetcode
点此进入如果可以的话,请点一下star,谢谢。
public class Solution { public int findNthDigit(int n) { int length=1; long count=9; while (n>count*length) { n-=count*length; length++; count*=10; } long target=count/9+(n-1)/length; return Integer.parseInt(String.valueOf(target).substring((n-1)%length, (n-1)%length+1)); } }
相关文章推荐
- 【LeetCode】 400. Nth Digit
- leetcode 400. Nth Digit解题报告
- LeetCode 400. Nth Digit
- LeetCode - 400. Nth Digit
- LeetCode-400. Nth Digit
- leetcode 400. Nth Digit
- 【C语言】 LeetCode 400. Nth Digit
- 【Leetcode】400. Nth Digit
- (Leetcode)400. Nth Digit
- Leetcode 400. Nth Digit (Easy) (cpp)
- LeetCode 400. Nth Digit
- LeetCode-400. Nth Digit
- leetcode_400. Nth Digit 查找自然数序列中的第n个数字
- leetcode 400. Nth Digit 从1到n第n位数字是什么 + 找规律
- LeetCode 400. Nth Digit
- LeetCode | 400. Nth Digit 数学原理题
- [Leetcode] 400. Nth Digit 解题报告
- [leetcode] 400. Nth Digit 解题报告
- LeetCode 400. Nth Digit
- [LeetCode]--400. Nth Digit