上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页
摘要: # 解题思路:用查找表(集合),保存其K个值的状态 20190302 找工作期间class Solution(object): def containsNearbyDuplicate(self, nums, k): """ :type nums: List[int] :type k: int :rt 阅读全文
posted @ 2019-03-17 14:37 AceKo 阅读(142) 评论(0) 推荐(0)
摘要: # 解题思路:字典存储计数状态 20190302 找工作期间class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ record = {} for i 阅读全文
posted @ 2019-03-17 14:36 AceKo 阅读(91) 评论(0) 推荐(0)
摘要: #coding=utf-8# 解题思路: 查找表 20190302 找工作期间class Solution(object): def isHappy(self, n): """ :type n: int :rtype: bool """ temp_res = [] while True: n = s 阅读全文
posted @ 2019-03-17 14:35 AceKo 阅读(96) 评论(0) 推荐(0)
摘要: # 解题思路:字典建立隐射关系,一一对应 20190302 找工作期间class Solution(object): def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ # 使用字典,pattern 阅读全文
posted @ 2019-03-17 14:35 AceKo 阅读(112) 评论(0) 推荐(0)
摘要: #coding=utf-8# 解题思路: 斜率查找表 20190302 找工作期间# Definition for a point.# class Point(object):# def __init__(self, a=0, b=0):# self.x = a# self.y = bclass S 阅读全文
posted @ 2019-03-17 14:34 AceKo 阅读(144) 评论(0) 推荐(0)
摘要: class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ ans, res, ret = [], {}, [] for s in strs: 阅读全文
posted @ 2019-03-17 14:33 AceKo 阅读(120) 评论(0) 推荐(0)
摘要: # 解题思路:查找表 20190302 找工作期间# 哈希表能将查找的复杂度从o(n)降到 o(1)class Solution(object): def fourSum(self, nums, target): """ :type nums: List[int] :type target: int 阅读全文
posted @ 2019-03-17 14:32 AceKo 阅读(134) 评论(0) 推荐(0)
摘要: #coding=utf-8# 解题思路:查找表 n2 20190302 找工作期间# 排序数组的双指针求和法 : (0,n) -> (a,b)# 其中a只能增加 b只能减少 : 搜索方向的问题 ,不然会到重复的状态class Solution(object): def threeSum(self, 阅读全文
posted @ 2019-03-17 14:29 AceKo 阅读(134) 评论(0) 推荐(0)
摘要: #coding=utf-8# 解题思路: 排序 + 双指针求和 20190302 找工作期间class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: 阅读全文
posted @ 2019-03-17 14:29 AceKo 阅读(131) 评论(0) 推荐(0)
摘要: #coding=utf-8# 解题思路:查找表 适合只有唯一解的情况 20190302 找工作期间class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int : 阅读全文
posted @ 2019-03-17 14:28 AceKo 阅读(185) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页