Skip to content

Commit 731f7dc

Browse files
committed
remote dups
1 parent b079f2a commit 731f7dc

File tree

237 files changed

+37
-5290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+37
-5290
lines changed

.DS_Store

10 KB
Binary file not shown.

102.二叉树的层序遍历/102-二叉树的层序遍历.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

11.盛最多水的容器/11-盛最多水的容器.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

1150.检查一个数是否在数组中占绝大多数/1150-检查一个数是否在数组中占绝大多数.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ def isMajorityElement(self, nums, target):
55
:type target: int
66
:rtype: bool
77
"""
8-
return nums.count(target) > (len(nums) // 2)
8+
return nums.count(target) > len(nums) // 2

116.填充每个节点的下一个右侧节点指针/116-填充每个节点的下一个右侧节点指针.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

117.填充每个节点的下一个右侧节点指针II/117-填充每个节点的下一个右侧节点指针II.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

1170.比较字符串最小字母出现频次/1170-比较字符串最小字母出现频次.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ def numSmallerByFrequency(self, queries, words):
55
:type words: List[str]
66
:rtype: List[int]
77
"""
8-
def f(word):
9-
return word.count(min(word))
108

11-
f_words = sorted([f(word) for word in words])
9+
def func(word):
10+
for char in "abcdefghijklmnopqrstuvwxyz":
11+
if char in word:
12+
return word.count(char)
13+
return 0
1214

13-
res = []
14-
# print f_words
15-
for q in queries:
16-
cnt = f(q)
17-
# print(bisect.bisect(f_words, cnt))
18-
res.append(len(f_words) - bisect.bisect(f_words, cnt))
19-
20-
return res
21-
15+
def func2(word):
16+
record = collections.Counter(word)
17+
return record[min(record.keys())]
18+
19+
20+
words_count = sorted(map(func2, words))
21+
queries_count = map(func2, queries)
22+
# print words_count, queries_count
23+
ans = []
24+
for query in queries_count:
25+
index = bisect.bisect(words_count, query) #bisect可以迅速找出有index个数 <= query
26+
ans.append(len(words_count) - index)# 减法找有多少个数比query大
27+
return ans
2228

1209.删除字符串中的所有相邻重复项II/1209-删除字符串中的所有相邻重复项II.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

121.买卖股票的最佳时机/121-买卖股票的最佳时机.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

1219.黄金矿工/1219-黄金矿工.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)