LeetCode 400. Nth Digit
2016-12-01 21:50
232 查看
public class Solution { public int findNthDigit(int n) { int level = 1; long count = level * 9 * (long)Math.pow(10, level - 1); while (n > count) { n -= count; level++; count = level * 9 * (long)Math.pow(10, level - 1); } int div = (n - 1) / level; int res = (n - 1) % level; long num = (long)Math.pow(10, level - 1) + div; return (int)(num / (long)Math.pow(10, level - res - 1) % 10); } }
相关文章推荐
- LeetCode - 400. Nth Digit
- 【C语言】 LeetCode 400. Nth Digit
- leetcode 400. Nth Digit 从1到n第n位数字是什么 + 找规律
- Leetcode 400. Nth Digit[easy]
- LeetCode 400. Nth Digit
- leetcode 400. Nth Digit解题报告
- LeetCode-400. Nth Digit
- LeetCode 400. Nth Digit
- 【Leetcode】400. Nth Digit
- [Leetcode] 400. Nth Digit 解题报告
- LeetCode 400. Nth Digit
- leetcode 400. Nth Digit
- Leetcode 400. Nth Digit (Easy) (cpp)
- LeetCode400. Nth Digit
- leetcode_400. Nth Digit 查找自然数序列中的第n个数字
- 【leetcode】400. Nth Digit(Python & C++)
- [LeetCode]400. Nth Digit(规律)
- leetcode 400. Nth Digit
- [leetcode] 400. Nth Digit 解题报告
- LeetCode—400. Nth Digit