Leetcode 400 Nth Digit
来源:互联网 发布:sql count 用法 编辑:程序博客网 时间:2024/05/17 10:42
Leetcode 400 Nth Digit
using namespace std;class Solution {public: int findNthDigit(int n) { long numBit = 1;//long is necessary 1,2,3,4 bits of number long interval = 9;//1*9 2*90 3*900 …… long num = 1;//position while(n > interval * numBit) { n -= interval * numBit; numBit ++; num += interval; interval *= 10; } int i = (n - 1) / numBit; i += num; int j = (n - 1) % numBit; return to_string(i)[j] - '0';//i is the number such as 80,if j == 0(0th bit),result is 8 }};
阅读全文
0 0
- LeetCode 400 Nth Digit
- Leetcode 400 Nth Digit
- Leetcode 400 Nth Digit
- 【LeetCode】400 Nth Digit(java实现)
- 【Leetcode】400. Nth Digit
- [Leetcode] 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 Nth Digit
- LeetCode 400. Nth Digit
- [leetcode]400. Nth Digit
- Leetcode 400. Nth Digit
- LeetCode 400. Nth Digit
- 【LeetCode】 400. Nth Digit
- 第三周——项目一—顺序表的基本运算(3)
- CXTPRibbonBar添加系统菜单时候,会出现白条
- License Key Formatting 问题及解法
- Leetcode 242 Valid Anagram
- Training Neural Networks with Very Little Data -- A Draft径向变换
- Leetcode 400 Nth Digit
- USB充电,标准充电器,非标准充电器的区别
- Leetcode 441 Arranging Coins
- 如何将拷贝过来的代码实现高亮
- Leetcode 561 Array Partition I
- 前端技术介绍,跟我学响应式布局
- 关于pod导入protocolBuffers使用问题
- Leetcode 605 Can Place Flowers
- 1464:最低等级