python leetcode 400. Nth Digit
按著題目意思程式設計即可
class Solution(object): def findNthDigit(self, n): """ :type n: int :rtype: int """ count=1 res=0 while (res+count*9*10**(count-1))<=n: res+=count*9*10**(count-1) count+=1 ds = n-res if ds==0:return 9 yu=ds%count if yu==0: dd=10**(count-1)+ds//count-1 return int(str(dd)[-1]) else: dd=10**(count-1)+ds//count return int(str(dd)[yu-1])
相關推薦
python leetcode 400. Nth Digit
按著題目意思程式設計即可 class Solution(object): def findNthDigit(self, n): """ :type n: int :rtype: int """ cou
[leetcode]400. Nth Digit
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
[leetcode] 400. Nth Digit 解題報告
題目連結:https://leetcode.com/problems/nth-digit/ Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ..
LeetCode-400. Nth Digit
問題:https://leetcode.com/problems/nth-digit/?tab=Description Find the nth digit of the infinite integ
LeetCode筆記:400. Nth Digit
問題: 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 wi
400. Nth Digit
not 變量 char tar 字符串 一個 一位 要求 out Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n is
400. Nth Digit 第N位
courier its rst clas borde color str for san Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...No
leetcode (Nth Digit)
Title:Nth Dight 400 Difficulty:Easy 原題leetcode地址: https://leetcode.com/problems/nth-digit/ 1. 數學
leetcode【400】Nth Digit(python)
寫在最前面: 為什麼我覺得這道簡單的題好難啊...感覺自己是個數學渣渣 純原創,不會有人和我一樣奇葩的思路的... leetcode【400】Nth Digit Find the nth digit of the infinite intege
[LeetCode] Nth Digit
ati pan 計算 lee tput 整數 esc ive leet Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note:n is
LeetCode 400. 第N個數字(C++、python)
在無限的整數序列 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...中找到第 n 個數字。 注意:n 是正數且在32為整形範圍內 ( n < 231)。 示例 1: 輸入: 3 輸出:
LeetCode演算法題-Nth Digit(Java實現)
這是悅樂書的第215次更新,第228篇原創 01 看題和準備 今天介紹的是LeetCode演算法題中Easy級別的第83題(順位題號是400)。找到無限整數序列的第n個數字1,2,3,4,5,6,7,8,9,10,11 ......例如: 輸入:3 輸出:3 輸入:11 輸出:0 說明:序列1,2,
[Leetcode] remove nth node from the end of list 刪除鏈表倒數第n各節點
truct def 倒數 move col lis remove str class Given a linked list, remove the n th node from the end of list and return its head. For exampl
【python/leetcode/M/87】Scramble String
題目 https://leetcode.com/problems/scramble-string/ 基本思路 要判斷兩個字元S和T能否轉化,先把它們各自分為兩部分,如果S的前半部分和T的前半部分能轉換,它們的後半部分也能轉換,說明它們就能轉換;但也有可能S的前半部分和後半部分
【python/leetcode/M】Binary Search Tree Iterator
題目 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() wi
【python/leetcode/M】Bitwise AND of Numbers Range
題目 Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. Example
【python/leetcode/130/M】Surrounded Regions
題目 https://leetcode.com/problems/surrounded-regions/ 基本思路 轉換一下思路,找出哪些O是沒有被X包圍的。在面板四周的O肯定是沒有被X包圍的,與它們相連的O也是沒有被包圍的,其它的O都是被X包圍的。 問題簡化為將與四周的
【python/leetcode/135/Hard】Candy
題目 https://leetcode.com/problems/candy/ 基本思路 題目要求比其高的鄰居要比本身的獎勵多,那麼最少也要多一個,所有我們可以找到所有的凹點,凹點如上三種情形。 找到所有的凹點後,我們就可以從凹點處開始向左右兩個方向依次查詢遞增序列,其
【python/leetcode/127】Word Ladder
題目 https://leetcode.com/problems/word-ladder 實現程式碼 class Solution(object): def ladderLength(self, beginWord, endWord, wordList):
【python/leetcode/M/97】Interleaving String
題目 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbb