leetcode400

package
v0.0.0-...-a94f1ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

README

第N个数字

  • 1-9 有 9 个数字,数字位数是 1;
  • 10-99 有 90 个数字,数字位数是 2;
  • 100-999 有 900 个数字, 数字位数是 3;
  • ……

所以可以将 n 简化成每个区间内的 m 位置。m 对应的数字又可以通过除以每个区间的数字位数得到,然后去掉尾数则可以得到最后的数字。

Documentation

Overview

* @lc app=leetcode id=400 lang=golang * * [400] Nth Digit * * https://leetcode.com/problems/nth-digit/description/ * * algorithms * Medium (30.99%) * Likes: 310 * Dislikes: 951 * Total Accepted: 53.8K * Total Submissions: 173.6K * Testcase Example: '3' * * Find the n^th digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, * 9, 10, 11, ... * * Note: * n is positive and will fit within the range of a 32-bit signed integer (n < * 2^31). * * * Example 1: * * Input: * 3 * * Output: * 3 * * * * Example 2: * * Input: * 11 * * Output: * 0 * * Explanation: * The 11th 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. * *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL