400. Nth Digit Medium

@problem@discussion
#Math#Binary Search



1/**
2 * [400] Nth Digit
3 *
4 * Given an integer n, return the n^th digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...].
5 *  
6 * Example 1:
7 * 
8 * Input: n = 3
9 * Output: 3
10 * 
11 * Example 2:
12 * 
13 * Input: n = 11
14 * Output: 0
15 * Explanation: The 11^th 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.
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= n <= 2^31 - 1
21 * 
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/nth-digit/
26// discuss: https://leetcode.com/problems/nth-digit/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31    pub fn find_nth_digit(n: i32) -> i32 {
32        0
33    }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40    use super::*;
41
42    #[test]
43    fn test_400() {
44    }
45}
46


Back
© 2025 bowen.ge All Rights Reserved.