feat: implement WildcardPatternMatching DP solution#21
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add WildcardPatternMatching static utility with a 2-D DP matches() method supporting '*' (any sequence) and '?' (exactly one char), plus thorough JUnit 5 tests covering null validation, empty-string edge cases, all-stars patterns, the three assignment examples, and exact character matching. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
WildcardPatternMatchingfinal utility class with a single public static methodmatches(String text, String pattern)dp[i][j]= pattern[0..i-1] matches text[0..j-1]) with standard wildcard transitions for*and?IllegalArgumentExceptionon nulltextor nullpatternTest plan
rejectsNullText— null text throwsIllegalArgumentExceptionrejectsNullPattern— null pattern throwsIllegalArgumentExceptionemptyPatternMatchesEmptyString—("", "") → trueemptyPatternDoesNotMatchNonEmptyString—("a", "") → falseallStarsPatternMatchesEmptyString—("", "***") → trueallStarsPatternMatchesAnyString—("anything goes here", "***") → true("xyxzzxy", "x***y") → true("xyxzzxy", "x***x") → false("xyxzzxy", "x***x?") → true?matches exactly one character?does not match empty string?does not match two characters?in middle of pattern matches any single char🤖 Generated with Claude Code