added 3 DSA questions in python#13373
added 3 DSA questions in python#13373PranavKuruvella wants to merge 13 commits intoTheAlgorithms:masterfrom PranavKuruvella:master
Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| from collections import defaultdict | ||
|
|
||
| class FruitIntoBaskets: | ||
| def total_fruit(self, fruits: List[int]) -> int: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_structures/arrays/fruit_into_baskets.py, please provide doctest for the function total_fruit
| from typing import List | ||
|
|
||
| class LongestOnesAfterReplacement: | ||
| def longest_ones(self, nums: List[int], k: int) -> int: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_structures/arrays/longest_ones_after_replacement.py, please provide doctest for the function longest_ones
Please provide descriptive name for the parameter: k
| from typing import List | ||
|
|
||
| class SlidingWindowMaximum: | ||
| def max_sliding_window(self, nums: List[int], k: int) -> List[int]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_structures/arrays/sliding_window_maximum.py, please provide doctest for the function max_sliding_window
Please provide descriptive name for the parameter: k
for more information, see https://pre-commit.ci
Updated the class docstring to provide a clearer problem statement and example usage.
for more information, see https://pre-commit.ci
Updated the problem statement and example in the docstring. Changed parameter name from 'k' to 'max_zero_flips' for clarity.
for more information, see https://pre-commit.ci
Updated the method to use 'window_size' instead of 'k' for clarity. Added docstring examples for better understanding.
for more information, see https://pre-commit.ci
Updated type hint for fruits parameter from List[int] to list[int].
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Closing require_descriptive_names PRs to prepare for Hacktoberfest |
Describe your change:
This PR adds three sliding-window Python utilities for working with arrays. SlidingWindowMaximum finds the maximum value in each window of size
k, LongestOnesAfterReplacement calculates the length of the longest subarray of 1s after flipping up tokzeros, and FruitIntoBaskets determines the maximum number of fruits you can collect from a subarray containing at most two types. All solutions use efficient sliding window techniques and run in linear time.Checklist: