Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Nth Digit

XPChallenge Points: 20
levelLevel: Medium

Consider writing all positive integers continuously without any spaces:

123456789101112131415...

This forms an infinite sequence of digits.
You are given an integer n, and you need to return the digit that appears at the n-th position (1-based) in this sequence.

Example 1:

Input: n = 5

Output: 5

Explanation:

Sequence: "12345...", the 5th digit is 5.

Example 2:

Input: n = 12

Output: 1

Explanation:

Sequence: "1234567891011..." The 12th digit lies in the number "10", specifically the '1'.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result