Skip to content

Conversation

Anubhav-pandey004
Copy link
Contributor

Description

This PR adds an implementation of the Minimum Window Substring problem and its corresponding unit tests under 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 frequency hash maps)

Code Summary

Added MinimumWindowSubstring.java

Uses two hash maps (tFreq, windowFreq) and two pointers (left, right) to maintain the sliding window.

Returns the smallest valid substring containing all characters of t, or "" if no window exists.

Added MinimumWindowSubstringTest.java

Includes JUnit tests to validate correctness.

Covers multiple scenarios: basic matches, exact matches, and no-solution cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant