Get Longest Match

Problem Overview

  • Find the length of the longest substring of a text that matches a regex with exactly one '*' wildcard (matching any sequence of lowercase letters).
  • Input: text and regex strings; Output: integer length of the longest match, or -1 if none.
  • Constraints: 1 <= |text|, |regex| <= 1e6; text is lowercase; regex is lowercase plus one '*'.
  • Real-world domain: string matching library for search/services.
  • Amazon interviews: an interview question and coding interview problem from Amazon.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: