Added Maximum Sliding Window algorithm using deque for efficient O(n) solution.
- [x] I have read CONTRIBUTING.md.
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
- [x] All new code is formatted with
clang-format -i --style=file path/to/your/file.java
Codecov Report
Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
Project coverage is 72.34%. Comparing base (
3da16a7) to head (2d084f4).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...com/thealgorithms/others/MaximumSlidingWindow.java | 92.85% | 0 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #5848 +/- ##
============================================
+ Coverage 72.32% 72.34% +0.01%
- Complexity 4965 4975 +10
============================================
Files 651 652 +1
Lines 17562 17576 +14
Branches 3385 3389 +4
============================================
+ Hits 12702 12715 +13
Misses 4382 4382
- Partials 478 479 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Pull Request Description Title: Add Maximum Sliding Window Algorithm Implementation
Overview: This pull request adds an implementation of the Maximum Sliding Window algorithm using a deque (double-ended queue) for efficient O(n) time complexity. The algorithm allows you to find the maximum value in every sliding window of size k in an array of integers.
Key Features:
Efficient Implementation: Utilizes a deque to maintain the indices of useful elements in the current window, allowing for optimal performance. Input and Output: Input: An array of integers and a window size k. Output: An array of the maximum values for each sliding window. Space Complexity: O(k) for the deque, which holds at most k elements at any time.
Feedback: I welcome any feedback or suggestions for improvements on this implementation.