Skip to content

Commit 24f2cc3

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4496f7c commit 24f2cc3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

data_structures/arrays/sublists.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ def generate_sublists_recursive(lst: list[int]) -> list[list[int]]:
55
>>> generate_sublists_recursive([1, 2, 3])
66
[[], [1], [1, 2], [1, 2, 3], [2], [2, 3], [3]]
77
"""
8+
89
def helper(start: int) -> None:
910
if start == len(lst):
1011
return
1112
for end in range(start + 1, len(lst) + 1):
1213
result.append(lst[start:end])
1314
helper(start + 1)
14-
15+
1516
result: list[list[int]] = [[]]
1617
helper(0)
1718
return result
@@ -24,13 +25,14 @@ def generate_sublists_backtrack(lst: list[int]) -> list[list[int]]:
2425
>>> generate_sublists_backtrack([1, 2, 3])
2526
[[], [1], [1, 2], [1, 2, 3], [2], [2, 3], [3]]
2627
"""
28+
2729
def backtrack(start: int, current: list[int]) -> None:
2830
result.append(current[:])
2931
for end in range(start, len(lst)):
3032
current.append(lst[end])
3133
backtrack(end + 1, current)
3234
current.pop()
33-
35+
3436
result: list[list[int]] = []
3537
backtrack(0, [])
3638
return result

0 commit comments

Comments
 (0)