We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e78e5f6 commit 16ff978Copy full SHA for 16ff978
dynamic_programming/largest_divisible_subset.py
@@ -38,9 +38,9 @@ def largest_divisible_subset(array: list[int]) -> list[int]:
38
hash_array = list(range(array_size))
39
40
# Iterate through the array
41
- for i in range(array_size):
+ for i, item in enumerate(array):
42
for prev_index in range(i):
43
- if array[i] % array[prev_index] == 0 and 1 + memo[prev_index] > memo[i]:
+ if item % array[prev_index] == 0 and 1 + memo[prev_index] > memo[i]:
44
memo[i] = 1 + memo[prev_index]
45
hash_array[i] = prev_index
46
0 commit comments