![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LintCode答案
Tingway
这个作者很懒,什么都没留下…
展开
-
LintCode Python 丑数II
class Solution: """ @param {int} n an integer. @return {int} the nth prime number as description. """ def nthUglyNumber(self, n): # write your code here L = [0原创 2017-08-13 19:19:50 · 378 阅读 · 0 评论 -
LintCode Python 54.转换字符串到整数
def atoi(self, str): # write your code here str = str.strip() if (str == '' or str[0] == '.' or '-' in str[1:] or str.count('.') > 1 o...原创 2018-03-10 18:15:59 · 192 阅读 · 0 评论 -
LintCode Python 78.公共子串
Ldef longestCommonPrefix(self, strs): # write your code here if '' in strs or strs == []: return '' s, n = '', '' for j in range(min([len(i) for i in strs])): for i in ...原创 2018-03-09 21:21:55 · 152 阅读 · 0 评论 -
LintCode Python 79.最长公共子串
def longestCommonSubstring(self, A, B): # write your code here if A == '' or B == '': return 0 if len(A) >= len(B): L, L1 = A[:], B[:] el...原创 2018-03-09 20:33:21 · 201 阅读 · 0 评论 -
LintCode Python 171.乱序字符串
def anagrams(self, strs): # write your code here L = [i if len(i) <= 1 else sorted(i) for i in strs] return [strs[i] for i in range(len(L)) if L.count(L[i]) > 1]原创 2018-03-09 19:55:40 · 337 阅读 · 0 评论 -
LintCode Python 55.比较字符串
def compareStrings(A, B): # write your code here if len(A) < len(B): return False if len(A) == len(B): return(sorted(A) == sorted(B)) for i in B: if A.count(...原创 2018-03-09 19:56:59 · 373 阅读 · 1 评论 -
LintCode Python 合并排序数组
class Solution: #@param A and B: sorted integer array A and B. #@return: A new sorted integer array def mergeSortedArray(self, A, B): # write your code here return sorted(A原创 2017-08-13 19:35:58 · 397 阅读 · 0 评论 -
LintCode Python 第k大元素
class Solution: # @param k & A a integer and an array # @return ans a integer def kthLargestElement(self, k, A): A = sorted(A, reverse=True) return A[k-1]原创 2017-08-13 19:32:04 · 798 阅读 · 0 评论 -
LintCode Python 统计数字
class Solution: # @param k & n two integer # @return ans a integer def digitCounts(self, k, n): L = ''.join([str(i) for i in range(n+1)]) c = L.count(str(k)) retur原创 2017-08-13 19:17:24 · 806 阅读 · 0 评论 -
LintCode Python 尾部的零
class Solution: # @param n a integer # @return as a integer def trailingZeros(self, n): if n == 0: return 1 x = 0 while n > 5: x += n //原创 2017-08-13 19:14:39 · 263 阅读 · 1 评论 -
LintCode Python 101. 删除排序数组中的重复数字 II
def removeDuplicates(self, nums): # write your code here if nums == []: return 0 index,count = 0, 1 for i in range(1, len(nums)): if nums[index] == nums[i] and count &l...原创 2018-03-10 20:50:55 · 413 阅读 · 0 评论