LeetCode—400. Nth Digit
来源:互联网 发布:苏州 青少年编程 编辑:程序博客网 时间:2024/05/21 00:45
Nth Digit思路:先找出这是第哪个数,然后确定是这个数的第几位,观察可得,一位数有9个,1-9,二位数有90个,10-99,三位数有900个,100-999,以此类推
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)); }}
0 0
- LeetCode—400. Nth Digit
- 【Leetcode】400. Nth Digit
- leetcode 400. Nth Digit
- 400. Nth Digit (leetcode) 。。。
- [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
- LeetCode 400. Nth Digit
- LeetCode 400. Nth Digit
- LeetCode 400. Nth Digit
- LeetCode-400. Nth Digit
- [LeetCode]400. Nth Digit
- Android客户端代码保护技术-完整性校验
- Android入门教程 Service的用法
- Handler 和 Looper 来满足线程间的通信
- 读深入理解Linux内核 (前言和第一章)
- Inflate()---Android之Inflate()方法用途
- LeetCode—400. Nth Digit
- @RequestMapping注解方法返回值意义
- Centos7 Nexus Maven 开机启动
- Cocos2d-x下Lua调用自定义C++类和函数的最佳实践
- nodejs学习-post请求处理
- CSS:CSS概述与引用
- java自定义类加载器
- 前端兼容性问题总结
- android多分辨率多屏幕密度下UI适配方案