Skip to content

feat: implement WildcardPatternMatching DP solution#21

Merged
bushidocodes merged 2 commits into
masterfrom
feat/wildcard-pattern-matching
Jun 12, 2026
Merged

feat: implement WildcardPatternMatching DP solution#21
bushidocodes merged 2 commits into
masterfrom
feat/wildcard-pattern-matching

Conversation

@bushidocodes

Copy link
Copy Markdown
Owner

Summary

  • Add WildcardPatternMatching final utility class with a single public static method matches(String text, String pattern)
  • Uses a 2-D DP table (dp[i][j] = pattern[0..i-1] matches text[0..j-1]) with standard wildcard transitions for * and ?
  • Throws IllegalArgumentException on null text or null pattern

Test plan

  • rejectsNullText — null text throws IllegalArgumentException
  • rejectsNullPattern — null pattern throws IllegalArgumentException
  • emptyPatternMatchesEmptyString("", "") → true
  • emptyPatternDoesNotMatchNonEmptyString("a", "") → false
  • allStarsPatternMatchesEmptyString("", "***") → true
  • allStarsPatternMatchesAnyString("anything goes here", "***") → true
  • Assignment example 1: ("xyxzzxy", "x***y") → true
  • Assignment example 2: ("xyxzzxy", "x***x") → false
  • Assignment example 3: ("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
  • Exact match with no wildcards
  • No match with no wildcards
  • Pattern longer than text (no wildcards) → false
  • Text longer than pattern (no wildcards) → false

🤖 Generated with Claude Code

bushidocodes and others added 2 commits June 11, 2026 22:02
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>
@bushidocodes bushidocodes merged commit 747461b into master Jun 12, 2026
1 check passed
@bushidocodes bushidocodes deleted the feat/wildcard-pattern-matching branch June 12, 2026 02:12
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