0ms C++ solution


  • 0
    class Solution {
    public:
        int findNthDigit(int n) {
            int d = 1, base = 1;
            while ((long long)9 * base * d - n < 0) {
                n -= 9 * base * d++;
                base *= 10;
            }
            int num = --n / d + base;
            for (int i = 1; i < d - n % d; i++) num /= 10;
            return num % 10;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.