Tap here to switch tabs
Problem
Submissions

Problem: Nth Digit

med
30 min
Try to solve the Nth Digit problem.

Statement

You are given an integer n. Consider the infinite sequence formed by writing all positive integers in order and concatenating their decimal representations: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, .... Return the digit located at the nnth position in this sequence, using 11 based indexing.

Implement int findNthDigit(int n) to return that digit.

Constraints:

  • 1≤1 \leq n ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Nth Digit

med
30 min
Try to solve the Nth Digit problem.

Statement

You are given an integer n. Consider the infinite sequence formed by writing all positive integers in order and concatenating their decimal representations: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, .... Return the digit located at the nnth position in this sequence, using 11 based indexing.

Implement int findNthDigit(int n) to return that digit.

Constraints:

  • 1≤1 \leq n ≤231−1\leq 2^{31} - 1