Skip to content

Commit ed9860f

Browse files
authored
Update remove-comments.py
1 parent 4b608d3 commit ed9860f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/remove-comments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Time: O(n), n is the length of the source
2-
# Space: O(k), k is the max length of a line.
2+
# Space: O(k), k is the max length of a line
33

44
# Given a C++ program, remove comments from it.
55
# The program source is an array where source[i] is the i-th line of the source code.
@@ -87,11 +87,11 @@ def removeComments(self, source):
8787
:rtype: List[str]
8888
"""
8989
in_block = False
90-
result = []
90+
result, newline = [], []
9191
for line in source:
92-
i = 0
9392
if not in_block:
9493
newline = []
94+
i = 0
9595
while i < len(line):
9696
if not in_block and i+1 < len(line) and line[i:i+2] == '/*':
9797
in_block = True

0 commit comments

Comments
 (0)