Tap here to switch tabs
Problem
Submissions

Problem: Nth Digit

Nth Digit asks you to return the digit at a given one-based position in the infinite sequence formed by concatenating the decimal representations of all positive integers in order.

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

Nth Digit asks you to return the digit at a given one-based position in the infinite sequence formed by concatenating the decimal representations of all positive integers in order.

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