2021/04/13
impl Solution {
pub fn find_nth_digit(mut n: i32) -> i32 {
let mut m = n as i64;
let mut i = 1;
let mut k = 1;
while m > 9 * k * i {
m -= 9 * i * k;
i += 1;
k *= 10;
}
let y = (m - 1) % i;
let x = (m - 1) / i;
let target_num = k + x;
let s = target_num.to_string();
let result = s.chars().nth(y as usize).unwrap().to_digit(10).unwrap();
return result as i32;
}
}