Add Minimum Window Substring algorithm in Sliding Window package#6553
Merged
DenizAltunkapan merged 16 commits intoTheAlgorithms:masterfrom Oct 2, 2025
Merged
Add Minimum Window Substring algorithm in Sliding Window package#6553DenizAltunkapan merged 16 commits intoTheAlgorithms:masterfrom
DenizAltunkapan merged 16 commits intoTheAlgorithms:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6553 +/- ##
============================================
+ Coverage 75.60% 75.63% +0.03%
- Complexity 5724 5733 +9
============================================
Files 695 696 +1
Lines 19637 19666 +29
Branches 3812 3818 +6
============================================
+ Hits 14846 14874 +28
Misses 4213 4213
- Partials 578 579 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
hey @TheAlgorithms @DenizAltunkapan can you review it. I would like to contribute. |
Member
|
@Anubhav-pandey004 yes, im currently on vacation, so its hard to review it from my phone. Its going to take some time😆 |
DenizAltunkapan
requested changes
Oct 1, 2025
src/test/java/com/thealgorithms/slidingwindow/MinimumWindowSubstringTest.java
Show resolved
Hide resolved
Member
|
@Anubhav-pandey004 I think there might be a possible bug when assertEquals("AABBC", MinimumWindowSubstring.minWindow("AAABBC", "AABC")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds an implementation of the Minimum Window Substring problem to the com.thealgorithms.slidingwindow package.
The algorithm finds the smallest substring in s that contains all characters of t.
Time Complexity: O(n) (where n = length of s)
Space Complexity: O(|charset|) (for HashMaps storing frequencies)
Code Summary
Implemented Solution.minWindow(String s, String t) method.
Uses two hash maps:
tFreq → stores required character frequencies of t.
windowFreq → tracks character frequencies in current window.
Expands right pointer until all required characters are included.
Shrinks from left to minimize window length while still valid.
Returns the smallest valid substring, or "" if none exists.