Skip to content

Commit effe2cc

Browse files
committed
remove semicolons
1 parent 0fbb64a commit effe2cc

Some content is hidden

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

53 files changed

+73
-73
lines changed

Python/coin-change-2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def change(self, amount, coins):
99
:rtype: int
1010
"""
1111
dp = [0] * (amount+1)
12-
dp[0] = 1;
12+
dp[0] = 1
1313
for coin in coins:
1414
for i in xrange(coin, amount+1):
1515
dp[i] += dp[i-coin]

Python/convert-bst-to-greater-tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def convertBSTHelper(root, cur_sum):
1414
if root.right:
1515
cur_sum = convertBSTHelper(root.right, cur_sum)
1616
cur_sum += root.val
17-
root.val = cur_sum;
17+
root.val = cur_sum
1818
if root.left:
1919
cur_sum = convertBSTHelper(root.left, cur_sum)
2020
return cur_sum

Python/count-of-smaller-numbers-after-self.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ def insertNode(self, val):
121121
if node.val < curr.val:
122122
curr.count += 1 # Increase the number of left children.
123123
if curr.left:
124-
curr = curr.left;
124+
curr = curr.left
125125
else:
126-
curr.left = node;
126+
curr.left = node
127127
break
128128
else: # Insert right if larger or equal.
129129
if curr.right:

Python/count-univalue-subtrees.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class Solution(object):
55
# @param {TreeNode} root
66
# @return {integer}
77
def countUnivalSubtrees(self, root):
8-
[is_uni, count] = self.isUnivalSubtrees(root, 0);
9-
return count;
8+
[is_uni, count] = self.isUnivalSubtrees(root, 0)
9+
return count
1010

1111
def isUnivalSubtrees(self, root, count):
1212
if not root:

Python/data-stream-as-disjoint-intervals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def upper_bound(nums, target):
3737
while i != len(self.__intervals) and \
3838
end + 1 >= self.__intervals[i].start:
3939
start = min(start, self.__intervals[i].start)
40-
end = max(end, self.__intervals[i].end);
40+
end = max(end, self.__intervals[i].end)
4141
del self.__intervals[i]
4242
self.__intervals.insert(i, Interval(start, end))
4343

Python/design-excel-sum-formula.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def set(self, r, c, v):
2626
:type v: int
2727
:rtype: void
2828
"""
29-
self.__reset_dependency(r, c);
30-
self.__update_others(r, c, v);
29+
self.__reset_dependency(r, c)
30+
self.__update_others(r, c, v)
3131

3232

3333
def get(self, r, c):

Python/design-twitter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def getNewsFeed(self, userId):
4444
result = []
4545
while max_heap and len(result) < self.__number_of_most_recent_tweets:
4646
t, uid, curr = heapq.heappop(max_heap)
47-
nxt = curr + 1;
47+
nxt = curr + 1
4848
if nxt != len(self.__messages[uid]):
4949
heapq.heappush(max_heap, (-self.__messages[uid][-(nxt+1)][0], uid, nxt))
50-
result.append(self.__messages[uid][-(curr+1)][1]);
50+
result.append(self.__messages[uid][-(curr+1)][1])
5151
return result
5252

5353
def follow(self, followerId, followeeId):

Python/employee-importance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def getImportance(self, employees, id):
4444
while q:
4545
curr = q.popleft()
4646
employee = employees[curr-1]
47-
result += employee.importance;
47+
result += employee.importance
4848
for id in employee.subordinates:
4949
q.append(id)
5050
return result

Python/encode-n-ary-tree-to-binary-tree.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def encode(self, root):
2626
def encodeHelper(root, parent, index):
2727
if not root:
2828
return None
29-
node = TreeNode(root.val);
29+
node = TreeNode(root.val)
3030
if index+1 < len(parent.children):
3131
node.left = encodeHelper(parent.children[index+1], parent, index+1)
3232
if root.children:
33-
node.right = encodeHelper(root.children[0], root, 0);
33+
node.right = encodeHelper(root.children[0], root, 0)
3434
return node
3535

3636
if not root:
3737
return None
38-
node = TreeNode(root.val);
38+
node = TreeNode(root.val)
3939
if root.children:
4040
node.right = encodeHelper(root.children[0], root, 0)
4141
return node

Python/factor-combinations.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def getResult(self, n, result, factors):
1414
i = 2 if not factors else factors[-1]
1515
while i <= n / i:
1616
if n % i == 0:
17-
factors.append(i);
18-
factors.append(n / i);
19-
result.append(list(factors));
20-
factors.pop();
21-
self.getResult(n / i, result, factors);
17+
factors.append(i)
18+
factors.append(n / i)
19+
result.append(list(factors))
20+
factors.pop()
21+
self.getResult(n / i, result, factors)
2222
factors.pop()
2323
i += 1
2424

Python/falling-squares.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def update(self, L, R, h):
6363
if R & 1 == 0:
6464
self.__apply(R, h)
6565
R -= 1
66-
L /= 2; R /= 2
66+
L /= 2 R /= 2
6767
self.__pull(L0)
6868
self.__pull(R0)
6969

7070
def query(self, L, R):
7171
L += self.N
7272
R += self.N
73-
self.__push(L); self.__push(R)
73+
self.__push(L) self.__push(R)
7474
result = 0
7575
while L <= R:
7676
if L & 1:
@@ -79,7 +79,7 @@ def query(self, L, R):
7979
if R & 1 == 0:
8080
result = self.query_fn(result, self.tree[R])
8181
R -= 1
82-
L /= 2; R /= 2
82+
L /= 2 R /= 2
8383
return result
8484

8585

@@ -90,7 +90,7 @@ class Solution2(object):
9090
def fallingSquares(self, positions):
9191
index = set()
9292
for left, size in positions:
93-
index.add(left);
93+
index.add(left)
9494
index.add(left+size-1)
9595
index = sorted(list(index))
9696
tree = SegmentTree(len(index), max, max)
@@ -137,7 +137,7 @@ def update(heights, left, right, B, blocks, blocks_read, h):
137137

138138
index = set()
139139
for left, size in positions:
140-
index.add(left);
140+
index.add(left)
141141
index.add(left+size-1)
142142
index = sorted(list(index))
143143
W = len(index)

Python/find-mode-in-binary-search-tree.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def inorder(root, prev, cnt, max_cnt, result):
1818
else:
1919
cnt = 1
2020
if cnt > max_cnt:
21-
max_cnt = cnt;
21+
max_cnt = cnt
2222
del result[:]
2323
result.append(root.val)
2424
elif cnt == max_cnt:
@@ -28,6 +28,6 @@ def inorder(root, prev, cnt, max_cnt, result):
2828
if not root:
2929
return []
3030
result = []
31-
inorder(root, None, 1, 0, result);
31+
inorder(root, None, 1, 0, result)
3232
return result
3333

Python/flip-game-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def canWin(self, s):
1212
g, g_final = [0], 0
1313
for p in itertools.imap(len, re.split('-+', s)):
1414
while len(g) <= p:
15-
# Theorem 2: g[game] = g[subgame1]^g[subgame2]^g[subgame3]...;
15+
# Theorem 2: g[game] = g[subgame1]^g[subgame2]^g[subgame3]...
1616
# and find first missing number.
1717
g += min(set(xrange(p)) - {x^y for x, y in itertools.izip(g[:len(g)/2], g[-2:-len(g)/2-2:-1])}),
1818
g_final ^= g[p]

Python/h-index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def hIndex(self, citations):
77
:type citations: List[int]
88
:rtype: int
99
"""
10-
n = len(citations);
10+
n = len(citations)
1111
count = [0] * (n + 1)
1212
for x in citations:
1313
# Put all x >= n in the same bucket.

Python/house-robber-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def robRange(self, nums, start, end):
1818
num_i, num_i_1 = nums[start], 0
1919
for i in xrange(start + 1, end):
2020
num_i_1, num_i_2 = num_i, num_i_1
21-
num_i = max(nums[i] + num_i_2, num_i_1);
21+
num_i = max(nums[i] + num_i_2, num_i_1)
2222

2323
return num_i
2424

Python/house-robber.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def rob(self, num):
1414
num_i, num_i_1 = max(num[1], num[0]), num[0]
1515
for i in xrange(2, len(num)):
1616
num_i_1, num_i_2 = num_i, num_i_1
17-
num_i = max(num[i] + num_i_2, num_i_1);
17+
num_i = max(num[i] + num_i_2, num_i_1)
1818

1919
return num_i
2020

Python/image-smoother.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def getGray(M, i, j):
2020
result = [[0 for _ in xrange(len(M[0]))] for _ in xrange(len(M))]
2121
for i in xrange(len(M)):
2222
for j in xrange(len(M[0])):
23-
result[i][j] = getGray(M, i, j);
23+
result[i][j] = getGray(M, i, j)
2424
return result
2525

Python/k-empty-slots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def kEmptySlots(self, flowers, k):
1717
if days[i] < days[left] or days[i] <= days[right]:
1818
if i == right:
1919
result = min(result, max(days[left], days[right]))
20-
left, right = i, k+1+i;
20+
left, right = i, k+1+i
2121
i += 1
2222
return -1 if result == float("inf") else result+1
2323

Python/kill-process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def killAll(pid, children, killed):
5050
q.append(kill)
5151
while q:
5252
p = q.popleft()
53-
result.append(p);
53+
result.append(p)
5454
for child in children[p]:
5555
q.append(child)
5656
return result

Python/knight-probability-in-chessboard.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def knightProbability(self, N, K, r, c):
1212
"""
1313
directions = \
1414
[[ 1, 2], [ 1, -2], [ 2, 1], [ 2, -1], \
15-
[-1, 2], [-1, -2], [-2, 1], [-2, -1]];
15+
[-1, 2], [-1, -2], [-2, 1], [-2, -1]]
1616
dp = [[[1 for _ in xrange(N)] for _ in xrange(N)] for _ in xrange(2)]
1717
for step in xrange(1, K+1):
1818
for i in xrange(N):
@@ -21,7 +21,7 @@ def knightProbability(self, N, K, r, c):
2121
for direction in directions:
2222
rr, cc = i+direction[0], j+direction[1]
2323
if 0 <= cc < N and 0 <= rr < N:
24-
dp[step%2][i][j] += 0.125 * dp[(step-1)%2][rr][cc];
24+
dp[step%2][i][j] += 0.125 * dp[(step-1)%2][rr][cc]
2525

2626
return dp[K%2][r][c]
2727

Python/kth-smallest-number-in-multiplication-table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def findKthNumber(self, m, n, k):
1212
def count(target, m, n):
1313
return sum(min(target//i, n) for i in xrange(1, m+1))
1414

15-
left, right = 1, m*n;
15+
left, right = 1, m*n
1616
while left <= right:
1717
mid = left + (right-left)/2
1818
if count(mid, m, n) >= k:

Python/longest-increasing-path-in-a-matrix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def longestpath(matrix, i, j, max_lengths):
2020
x, y = i + d[0], j + d[1]
2121
if 0 <= x < len(matrix) and 0 <= y < len(matrix[0]) and \
2222
matrix[x][y] < matrix[i][j]:
23-
max_depth = max(max_depth, longestpath(matrix, x, y, max_lengths));
23+
max_depth = max(max_depth, longestpath(matrix, x, y, max_lengths))
2424
max_lengths[i][j] = max_depth + 1
2525
return max_lengths[i][j]
2626

Python/longest-increasing-subsequence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def insert(target):
1919
left = mid + 1
2020
# If not found, append the target.
2121
if left == len(LIS):
22-
LIS.append(target);
22+
LIS.append(target)
2323
else:
2424
LIS[left] = target
2525

Python/max-stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def popMax(self):
6666

6767
def __remove(self, val):
6868
idx = self.__val_to_idxs[val][-1]
69-
self.__val_to_idxs[val].pop();
69+
self.__val_to_idxs[val].pop()
7070
if not self.__val_to_idxs[val]:
7171
del self.__val_to_idxs[val]
7272
del self.__idx_to_val[idx]

Python/max-sum-of-sub-matrix-no-larger-than-k.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def lower_bound(self, val): # Time: O(h) = O(logn) ~ O(n)
9494
accu_sum = 0
9595
for sum in sums:
9696
accu_sum += sum
97-
node = accu_sum_set.lower_bound(accu_sum - k);
97+
node = accu_sum_set.lower_bound(accu_sum - k)
9898
if node:
9999
result = max(result, accu_sum - node.val)
100100
accu_sum_set.insert(accu_sum)

Python/maximal-square.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ def maximalSquare(self, matrix):
110110
s[i][j] = side
111111
max_square_area = max(max_square_area, side * side)
112112

113-
return max_square_area;
113+
return max_square_area
114114

115115

Python/maximum-binary-tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def constructMaximumBinaryTree(self, nums):
1717
# https://github.com/kamyu104/LintCode/blob/master/C++/max-tree.cpp
1818
nodeStack = []
1919
for num in nums:
20-
node = TreeNode(num);
20+
node = TreeNode(num)
2121
while nodeStack and num > nodeStack[-1].val:
2222
node.left = nodeStack.pop()
2323
if nodeStack:

Python/maximum-sum-of-3-non-overlapping-subarrays.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def maxSumOfThreeSubarrays(self, nums, k):
2626
total = accu[n]-accu[n-k]
2727
for i in reversed(xrange(n-k)):
2828
if accu[i+k]-accu[i] > total:
29-
right_pos[i] = i;
29+
right_pos[i] = i
3030
total = accu[i+k]-accu[i]
3131
else:
3232
right_pos[i] = right_pos[i+1]

Python/median-of-two-sorted-arrays.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def findMedianSortedArrays(self, A, B):
8484
return -1.0
8585
lenA = len(A)
8686
lenB = len(B)
87-
lenn = lenA + lenB;
87+
lenn = lenA + lenB
8888

8989
indexA,indexB,indexC = 0,0,0
9090
C = [False for i in xrange(lenn)]

Python/merge-k-sorted-lists.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def mergeTwoLists(l1, l2):
3333

3434
if not lists:
3535
return None
36-
left, right = 0, len(lists) - 1;
36+
left, right = 0, len(lists) - 1
3737
while right > 0:
3838
if left >= right:
3939
left = 0

Python/mini-parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def deserialize(self, s):
6161
stk[-1].add(NestedInteger(int(s[i:j])))
6262
if s[j] == ']' and len(stk) > 1:
6363
cur = stk[-1]
64-
stk.pop();
64+
stk.pop()
6565
stk[-1].add(cur)
6666
i = j+1
6767

Python/most-common-word.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def mostCommonWord(self, paragraph, banned):
1212
:rtype: str
1313
"""
1414
lookup = set(banned)
15-
counts = collections.Counter(word.strip("!?',;.")
15+
counts = collections.Counter(word.strip("!?',.")
1616
for word in paragraph.lower().split())
1717

1818
result = ''

Python/n-queens.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def dfs(curr, cols, main_diag, anti_diag, result):
2929

3030
# For any point (x,y), if we want the new point (p,q) don't share the same row, column, or diagonal.
3131
# then there must have ```p+q != x+y``` and ```p-q!= x-y```
32-
# the former focus on eliminate 'left bottom right top' diagonal;
32+
# the former focus on eliminate 'left bottom right top' diagonal
3333
# the latter focus on eliminate 'left top right bottom' diagonal
3434

3535
# - col_per_row: the list of column index per row

Python/number-of-digit-one.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Solution(object):
55
# @param {integer} n
66
# @return {integer}
77
def countDigitOne(self, n):
8-
k = 1;
8+
k = 1
99
cnt, multiplier, left_part = 0, 1, n
1010

1111
while left_part > 0:

Python/number-of-distinct-islands-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def dfs(i, j, grid, island):
1515
grid[i][j] > 0):
1616
return False
1717
grid[i][j] *= -1
18-
island.append((i, j));
18+
island.append((i, j))
1919
for d in directions:
2020
dfs(i+d[0], j+d[1], grid, island)
2121
return True

0 commit comments

Comments
 (0)