Leetcode 400. Nth digits】的更多相关文章

解法一: 一个几乎纯数学的解法 numbers:   1,...,9, 10, ..., 99, 100, ... 999, 1000 ,..., 9999, ... # of digits:   9     +  90*2   +  900*3 + 9000*4 + ... 利用这个公式可以很容易的求出来Nth digit出现在一个几位数上.假设出现在一个4位数上.那么我们应该从1000的第一个1开始往后数 n - (9 + 90*2 + 900*3)个digits.那么第n个digits应该…
leetcode 400. Nth Digit 在线提交网址: https://leetcode.com/problems/nth-digit/ Total Accepted: 4356 Total Submissions: 14245 Difficulty: Easy Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - Note: n is positive and w…
https://leetcode.com/contest/5/problems/nth-digit/ 刚开始看不懂题意,后来才理解是这个序列连起来的,看一下第几位是几.然后就是数,1位数几个,2位数几个,3位数几个,int范围2e10,所以处理到11位数差不多,仔细算一下可以更少,然后先找到是几位数,然后除以位数,找到这个数是多少,取余看是第几位,然后就可以了.我预处理每位的个数和开始的位置. class Solution { public: ]; ]; int init(int n) { d[…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/reach-a-number/description/ 题目描述 Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - Note: n is posit…
Find the nth 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 < 231). Example 1: Input: 3 Output: 3 Example 2: Input: 11 Output: 0 Explanation…
#-*- coding: UTF-8 -*- class Solution(object):    def findNthDigit(self, n):        """        :type n: int        :rtype: int        """        res=n        if n>9:            index=1            mul=9            res=0    …
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Input contains only lowercase English letters. Input is guaranteed to be valid and can be transformed to its origina…
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero. Ex…
Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given…
Remove Nth Node From End of List Total Accepted: 46720 Total Submissions: 168596My Submissions Question Solution  Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5,…