上一页 1 2 3 4 5 6 7 8 ··· 51 下一页
摘要: 代码思路:用文件内容作key域,value域需要拼接,是文件全名。 import re class Solution(object): def findDuplicate(self, paths): """ :type paths: List[str] :rtype: List[List[str]] 阅读全文
posted @ 2020-11-23 15:49 人间烟火地三鲜 阅读(145) 评论(0) 推荐(0)
摘要: class Solution(object): def frequencySort(self, s): """ :type s: str :rtype: str """ mydict = {} for item in s: if item in mydict.keys(): mydict[item] 阅读全文
posted @ 2020-11-23 15:47 人间烟火地三鲜 阅读(115) 评论(0) 推荐(0)
摘要: 注:sorted()可以排字符串。 class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ mydict = {} for item in 阅读全文
posted @ 2020-11-23 15:45 人间烟火地三鲜 阅读(125) 评论(0) 推荐(0)
摘要: 代码一:快慢指针 class Solution(object): # 快慢指针 def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ slow, fast = head, head finder = he 阅读全文
posted @ 2020-11-23 15:42 人间烟火地三鲜 阅读(83) 评论(0) 推荐(0)
摘要: 代码一:双指针 class Solution(object): # 双指针 def pairSums(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[List[int]] """ if not 阅读全文
posted @ 2020-11-23 15:38 人间烟火地三鲜 阅读(95) 评论(0) 推荐(0)
摘要: class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ words = s.split() return ' '.join(words[::-1]) if __name__ == '__m 阅读全文
posted @ 2020-11-23 15:35 人间烟火地三鲜 阅读(84) 评论(0) 推荐(0)
摘要: class Solution(object): def uniqueOccurrences(self, arr): """ :type arr: List[int] :rtype: bool """ mydict = {} for item in arr: if item in mydict.key 阅读全文
posted @ 2020-11-23 15:32 人间烟火地三鲜 阅读(95) 评论(0) 推荐(0)
摘要: 代码一思路: 设两个指针cur、i,cur是有效元素下标,初值为0,i是从第一个元素开始的遍历指针;另外用count记录当前相同元素的个数; i和cur指向的元素相同且count值小于2,说明cur指向的元素出现第二次,为有效元素,cur、i右移,count计数器加1; i和cur指向的元素相同且c 阅读全文
posted @ 2020-11-23 15:30 人间烟火地三鲜 阅读(98) 评论(0) 推荐(0)
摘要: 代码一:用字典。 class Solution(object): def smallerNumbersThanCurrent(self, nums): """ :type nums: List[int] :rtype: List[int] """ mydict = {} temp = [] for 阅读全文
posted @ 2020-11-23 15:25 人间烟火地三鲜 阅读(124) 评论(0) 推荐(0)
摘要: class Solution(object): # 思路: # 从左往右遍历A,分别设置计数器记录上坡up和下坡down的长度; # 当不满足上坡了,就计数下坡; # 当下坡也不满足了,记录当前山脉的长度=up+down+1 # 遍历时若遇到两个元素相等,则跳过。 def longestMounta 阅读全文
posted @ 2020-11-23 15:22 人间烟火地三鲜 阅读(129) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 51 下一页