8000 Removed Unused Var `carry` in multiply_srings.py (#628) · LeetCode-Interview/algorithms@716c787 · GitHub
[go: up one dir, main page]

Skip to content

Commit 716c787

Browse files
0verk1llkeon
authored andcommitted
Removed Unused Var carry in multiply_srings.py (keon#628)
* Fix problems with testing equality to None. * Removed unused variable
1 parent 2f84f03 commit 716c787

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

algorithms/automata/dfa.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ def DFA(transitions, start, final, string):
33
num = len(string)
44
num_final = len(final)
55
cur = start
6-
7-
for i in range (num):
8-
9-
if transitions[cur][string[i]] == None:
6+
7+
for i in range(num):
8+
9+
if transitions[cur][string[i]] is None:
1010
return False
1111
else:
1212
cur = transitions[cur][string[i]]
1313

14-
for i in range (num_final):
14+
for i in range(num_final):
1515
if cur == final[i]:
1616
return True
1717
return False
18-

algorithms/graph/tarjan.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
from algorithms.graph.graph import DirectedGraph
77

8+
89
class Tarjan(object):
910
def __init__(self, dict_graph):
1011
self.graph = DirectedGraph(dict_graph)
@@ -18,7 +19,7 @@ def __init__(self, dict_graph):
1819

1920
self.sccs = []
2021
for v in self.graph.nodes:
21-
if v.index == None:
22+
if v.index is None:
2223
self.strongconnect(v, self.sccs)
2324

2425
def strongconnect(self, v, sccs):
@@ -31,7 +32,7 @@ def strongconnect(self, v, sccs):
3132

3233
# Consider successors of v
3334
for w in self.graph.adjmt[v]:
34-
if w.index == None:
35+
if w.index is None:
3536
# Successor w has not yet been visited; recurse on it
3637
self.strongconnect(w, sccs)
3738
v.lowlink = min(v.lowlink, w.lowlink)
@@ -41,7 +42,7 @@ def strongconnect(self, v, sccs):
4142
# Note: The next line may look odd - but is correct.
4243
# It says w.index not w.lowlink; that is deliberate and from the original paper
4344
v.lowlink = min(v.lowlink, w.index)
44-
45+
4546
# If v is a root node, pop the stack and generate an SCC
4647
if v.lowlink == v.index:
4748
# start a new strongly connected component
@@ -54,4 +55,3 @@ def strongconnect(self, v, sccs):
5455
break
5556
scc.sort()
5657
sccs.append(scc)
57-

algorithms/strings/multiply_strings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"""
1313

1414

15-
def multiply(num1:"str", num2:"str")->"str":
16-
carry = 1
15+
def multiply(num1: "str", num2: "str") -> "str":
1716
interm = []
1817
zero = ord('0')
1918
i_pos = 1

0 commit comments

Comments
 (0)
0