上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 2018 1. 简化版KNN算法写code实现,用Euclidean distance。(heap tree那里我是用heaplist实现的,出了个bug,而且写得太慢把时间耗光了) 2. 概率题,扔硬币,n次中有m次head,问是否能说明硬币是biased,写个函数算出来(经典题不难,但是没时间了 阅读全文
posted @ 2018-09-24 03:03 ffeng0312 阅读(344) 评论(0) 推荐(0)
摘要: class Solution(object): def findDuplicate(self, paths): """ :type paths: List[str] :rtype: List[List[str]] """ content_path={} for i in paths: splits= 阅读全文
posted @ 2018-09-15 03:43 ffeng0312 阅读(135) 评论(0) 推荐(0)
摘要: class Solution(object): def subseq(self,w1,w2): cnt=0 for i in w2: if cnt<len(w1) and i==w1[cnt]: cnt+=1 return cnt==len(w1) def findLUSlength(self, s 阅读全文
posted @ 2018-09-15 03:35 ffeng0312 阅读(193) 评论(0) 推荐(0)
摘要: #Runtime: 276 ms 阅读全文
posted @ 2018-09-14 06:33 ffeng0312 阅读(171) 评论(0) 推荐(0)
摘要: class Solution(object): def findLHS(self, nums): """ :type nums: List[int] :rtype: int """ cnt={} for num in nums: if num not in cnt: cnt[num]=1 else: 阅读全文
posted @ 2018-09-14 05:26 ffeng0312 阅读(133) 评论(0) 推荐(0)
摘要: class Solution(object): def mostCommonWord(self, paragraph, banned): """ :type paragraph: str :type banned: List[str] :rtype: str """ res='' cnt={res: 阅读全文
posted @ 2018-09-13 03:03 ffeng0312 阅读(157) 评论(0) 推荐(0)
摘要: class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ sub='' longest='' for i in s: if i not in sub: sub+=i 阅读全文
posted @ 2018-09-13 02:58 ffeng0312 阅读(128) 评论(0) 推荐(0)
摘要: class Solution(object): def numRabbits(self, answers): """ :type answers: List[int] :rtype: int """ cnt = {} for answer in answers: if answer not in c 阅读全文
posted @ 2018-09-11 22:54 ffeng0312 阅读(127) 评论(0) 推荐(0)
摘要: class Solution(object): def getHint(self, secret, guess): """ :type secret: str :type guess: str :rtype: str """ A=sum(a==b for a,b in zip(secret,gues 阅读全文
posted @ 2018-09-11 05:29 ffeng0312 阅读(170) 评论(0) 推荐(0)
摘要: class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ l = len(nums) for i in range(l): 阅读全文
posted @ 2018-09-08 03:35 ffeng0312 阅读(135) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 下一页