Camelcase Matching

MediumStringstwo pointers

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

A query string *matches* a pattern if you can build the query by inserting zero or more **lowercase** letters anywhere into pattern (before, between, or after its characters). Uppercase letters can never be inserted, and the pattern's own characters must appear in order. Given an array queries and a string pattern, return a boolean array whose i-th entry is true exactly when queries[i] matches pattern.

Examples

Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
Output: [true,false,true,true,false]
"FooBar" is F + "oo" + B + "ar". "FooBarTest" has an extra uppercase T; "ForceFeedBack" has an extra uppercase F.
Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
Output: [true,false,true,false,false]
"FootBall" is Fo + "ot" + Ba + "ll". "FrameBuffer" has no "a" after its B.

Constraints

  • `1 <= pattern.length, queries.length <= 100`
  • `1 <= queries[i].length <= 100`
  • All strings consist of English letters

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More two pointers problems