Skip to content

Commit ccc32fd

Browse files
Refactor total_fruit method parameter type hint
Updated type hint for fruits parameter from List[int] to list[int].
1 parent e245324 commit ccc32fd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

data_structures/arrays/fruit_into_baskets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
from typing import List
21
from collections import defaultdict
32

43

54
class FruitIntoBaskets:
65
"""
76
Problem:
8-
Given an array of integers representing types of fruit, pick a contiguous subarray
9-
containing at most two different types of fruit. Return the maximum number
10-
of fruits you can collect.
7+
Given an array of integers representing types of fruit, pick a contiguous
8+
subarray containing at most two different types of fruit. Return the maximum
9+
number of fruits you can collect.
1110
1211
Example:
1312
>>> solver = FruitIntoBaskets()
1413
>>> solver.total_fruit([1, 2, 1, 2, 3])
1514
4
1615
"""
1716

18-
def total_fruit(self, fruits: List[int]) -> int:
17+
def total_fruit(self, fruits: list[int]) -> int:
1918
count = defaultdict(int)
2019
left = 0
2120
max_fruit = 0
@@ -37,3 +36,4 @@ def total_fruit(self, fruits: List[int]) -> int:
3736
if __name__ == "__main__":
3837
solver = FruitIntoBaskets()
3938
print("Maximum Fruits Collected:", solver.total_fruit([1, 2, 1, 2, 3]))
39+

0 commit comments

Comments
 (0)