Intersection of Two Sets / Regex-Like Matcher

Problem Two parts. (1) Compute the intersection of two large sets of values. (2) Implement a simplified regex matcher supporting '.' (any single character) and '*' (zero or more of the preceding element), matching the full input string.

Input / Output

  • Part 1: two collections → the values present in both.
  • Part 2: string s and pattern p → boolean full match.

Constraints

  • Inputs may be large, so favour linear/near-linear work for the intersection.

Example

  • Intersection: {1,2,3,4} ∩ {2,4,6} → {2,4}.
  • Matcher: isMatch("aab", "cab") → true; isMatch("mississippi", "misisp*.") → false.
added …
LeaderboardSalaryAccount