上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 114 下一页
摘要: 1 import collections 2 class Solution: 3 def uniqueOccurrences(self, arr: List[int]) -> bool: 4 obj = collections.Counter(arr).items() 5 dic = {} 6 for o in obj: 7 if o[1] not in dic: 8 dic[o[1]] = o[ 阅读全文
posted @ 2019-10-04 15:27 Sempron2800+ 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 先将数据排序,然后计算相邻数组的差值,使用字典保存最小差值所包含的元素对。 阅读全文
posted @ 2019-10-04 15:18 Sempron2800+ 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/discuss/382775/Python3-straightforward-and-easiest-on-discussion 阅读全文
posted @ 2019-09-15 22:45 Sempron2800+ 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 算法思想:贪心+Hash。 记录b a l o n出现的次数,计算可以构成的单词的最少字符。 阅读全文
posted @ 2019-09-15 21:36 Sempron2800+ 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 最少立方数之和 题目描述给出一个数字N(0<N<1000000),将N写成立方数和的形式,求出需要的最少立方数个数。例如N=17,1+8+8 = 17,最少需要3个立方数,则输出3。N= 28,1+1+1+1+8+8+8=28, 需要7个立方数,1+27=28,需要2个立方数,所以最少立方数为2,则 阅读全文
posted @ 2019-09-11 09:11 Sempron2800+ 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 1 from datetime import datetime 2 3 class Solution: 4 def dayOfTheWeek(self, day: int, month: int, year: int) -> str: 5 days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sund 阅读全文
posted @ 2019-09-11 07:19 Sempron2800+ 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int: 3 if start == destination: 4 return 0 5 elif start < destination: 6 dis1,dis2 = 0,0 7 f 阅读全文
posted @ 2019-09-11 07:08 Sempron2800+ 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def factorial(self,N): 3 result = 1 4 while N > 0: 5 result *= N 6 N -= 1 7 return result 8 9 def numPrimeArrange... 阅读全文
posted @ 2019-09-10 21:14 Sempron2800+ 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 1 import collections 2 import bisect 3 4 class Solution: 5 def getFC(self,word): 6 obj = collections.Counter(word) 7 for i in range(97,123): 8 c = chr(i) 9 if c in obj: 10 return obj[c] 11 12 def numS 阅读全文
posted @ 2019-09-10 16:41 Sempron2800+ 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def isLeap(self,year): 3 if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): 4 return True 5 return False 6 7 def dayOfYea... 阅读全文
posted @ 2019-09-10 16:13 Sempron2800+ 阅读(150) 评论(0) 推荐(0) 编辑
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 114 下一页