摘要: 1 class Solution(object): 2 def spellchecker(self, wordlist: 'List[str]', queries: 'List[str]') -> 'List[str]': 3 wordlen = len(wordlist) 4 wordict = {}#存原始形式 5 wordi... 阅读全文
posted @ 2019-04-24 19:55 Sempron2800+ 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 从大到小寻找每个数字的位置,将其先移动到第一个位置,再将其移动到其数字应该的位置(index==num-1)。 阅读全文
posted @ 2019-04-24 18:42 Sempron2800+ 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 这道题目描述很清晰,直接两层循环,代码如下: 显然,时间复杂度O(n^2),这样会超时。 因此需要优化,把时间复杂度减少O(n),一般这种类型的题目,都是要从数学角度分析,寻找规律。 先贴代码: 这里比较关键的代码就是13~17行,对于前m项的连加和,模K的余数,如果是第一次出现,则在字典中进行“标 阅读全文
posted @ 2019-04-24 12:31 Sempron2800+ 阅读(164) 评论(0) 推荐(0) 编辑
摘要: New York is 3 hours ahead of California, 纽约时间比加州时间早三个小时, but it does not make California slow. 但加州时间并没有变慢。 Someone graduated at the age of 22, 有人22岁就毕 阅读全文
posted @ 2019-04-24 02:33 Sempron2800+ 阅读(588) 评论(0) 推荐(0) 编辑