<p>Given an integer <code>n</code>, return the <code>n<sup>th</sup></code> digit of the infinite integer sequence <code>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 3
<strong>Output:</strong> 3
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 11
<strong>Output:</strong> 0
<strong>Explanation:</strong> The 11<sup>th</sup> digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
</ul>

class Solution {
public:
    int findNthDigit(int n) {
        long long num=1;
        long long dig = 0;
        while(dig<n){
            if(num<10) dig+=1;
            else if(num<100) dig+=2;
            else if(num<1000) dig+=3;
            else if(num<10000) dig+=4;
            else if(num<100000) dig+=5;
            else if(num<1000000) dig+=6;
            else if(num<10000000) dig+=7;
            else if(num<100000000) dig+=8;
            else if(num<1000000000) dig+=9;
            else if(num<10000000000) dig+=10;

            if(dig>=n){
                while(num){
                    int mod = num%10;
                    num/=10;
                    if(dig == n) return mod;
                    dig--;
                }
            }
            num++;
        }
        return 0;
    }
};
7100