Skip to content

Commit 91e728f

Browse files
committed
style: format python code
* black -S .
1 parent 8ba8275 commit 91e728f

File tree

13 files changed

+15
-16
lines changed

13 files changed

+15
-16
lines changed

lcci/17.13.Re-Space/Solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ def respace(self, dictionary: List[str], sentence: str) -> int:
66
for i in range(1, n + 1):
77
dp[i] = dp[i - 1] + 1
88
for j in range(i):
9-
if sentence[j: i] in s:
9+
if sentence[j:i] in s:
1010
dp[i] = min(dp[i], dp[j])
1111
return dp[-1]

lcci/17.15.Longest Word/Solution.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def cmp(a, b):
3030
return -1 if a > b else 1
3131

3232
def dfs(w):
33-
return not w or any(trie.search(w[:i]) and dfs(w[i:]) for i in range(1, len(w) + 1))
33+
return not w or any(
34+
trie.search(w[:i]) and dfs(w[i:]) for i in range(1, len(w) + 1)
35+
)
3436

3537
words.sort(key=cmp_to_key(cmp))
3638
trie = Trie()

lcof2/剑指 Offer II 041. 滑动窗口的平均值/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class MovingAverage:
2-
32
def __init__(self, size: int):
43
self.arr = [0] * size
54
self.s = 0

solution/0300-0399/0346.Moving Average from Data Stream/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class MovingAverage:
2-
32
def __init__(self, size: int):
43
self.arr = [0] * size
54
self.s = 0

solution/0400-0499/0472.Concatenated Words/Solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def dfs(w):
2424
if node.children[idx] is None:
2525
return False
2626
node = node.children[idx]
27-
if node.is_end and dfs(w[i + 1:]):
27+
if node.is_end and dfs(w[i + 1 :]):
2828
return True
2929
return False
3030

solution/0500-0599/0588.Design In-Memory File System/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def search(self, path):
3030

3131

3232
class FileSystem:
33-
3433
def __init__(self):
3534
self.root = Trie()
3635

solution/0600-0699/0642.Design Search Autocomplete System/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def search(self, pref):
2525

2626

2727
class AutocompleteSystem:
28-
2928
def __init__(self, sentences: List[str], times: List[int]):
3029
self.trie = Trie()
3130
for a, b in zip(sentences, times):

solution/0700-0799/0745.Prefix and Suffix Search/Solution.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Trie:
22
def __init__(self):
33
self.children = [None] * 26
44
self.indexes = []
5-
5+
66
def insert(self, word, i):
77
node = self
88
for c in word:
@@ -11,7 +11,7 @@ def insert(self, word, i):
1111
node.children[idx] = Trie()
1212
node = node.children[idx]
1313
node.indexes.append(i)
14-
14+
1515
def search(self, pref):
1616
node = self
1717
for c in pref:
@@ -23,7 +23,6 @@ def search(self, pref):
2323

2424

2525
class WordFilter:
26-
2726
def __init__(self, words: List[str]):
2827
self.p = Trie()
2928
self.s = Trie()
@@ -49,4 +48,4 @@ def f(self, pref: str, suff: str) -> int:
4948

5049
# Your WordFilter object will be instantiated and called as such:
5150
# obj = WordFilter(words)
52-
# param_1 = obj.f(pref,suff)
51+
# param_1 = obj.f(pref,suff)

solution/1100-1199/1166.Design File System/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def search(self, w):
2727

2828

2929
class FileSystem:
30-
3130
def __init__(self):
3231
self.trie = Trie()
3332

solution/1200-1299/1268.Search Suggestions System/Solution.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def search(self, word):
2525

2626

2727
class Solution:
28-
def suggestedProducts(self, products: List[str], searchWord: str) -> List[List[str]]:
28+
def suggestedProducts(
29+
self, products: List[str], searchWord: str
30+
) -> List[List[str]]:
2931
products.sort()
3032
trie = Trie()
3133
for i, w in enumerate(products):
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class Solution:
22
def countDistinct(self, s: str) -> int:
33
n = len(s)
4-
return len({s[i: j] for i in range(n) for j in range(i + 1, n + 1)})
4+
return len({s[i:j] for i in range(n) for j in range(i + 1, n + 1)})

solution/2200-2299/2227.Encrypt and Decrypt Strings/Solution.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Encrypter:
2-
32
def __init__(self, keys: List[str], values: List[str], dictionary: List[str]):
43
self.mp = dict(zip(keys, values))
54
self.cnt = Counter(self.encrypt(v) for v in dictionary)

solution/2300-2399/2343.Query Kth Smallest Trimmed Number/Solution.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class Solution:
2-
def smallestTrimmedNumbers(self, nums: List[str], queries: List[List[int]]) -> List[int]:
2+
def smallestTrimmedNumbers(
3+
self, nums: List[str], queries: List[List[int]]
4+
) -> List[int]:
35
ans = []
46
for k, t in queries:
57
x = nums[:]

0 commit comments

Comments
 (0)