253. CamelCase Matching (Count)

MediumStringString

Given an array of queries and a pattern, return the number of queries that match the pattern. A query matches if you can insert lowercase letters into the pattern so it equals the query (uppercase letters must align exactly and in order). Input: JSON {queries, pattern}.

Input: JSON {queries, pattern}.

Output: Integer — number of matching queries.

Examples

Example 1
Input: {"queries":["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"],"pattern":"FB"}
Output: 4
Explanation: All but FooBarTest match FB.
Example 2
Input: {"queries":["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"],"pattern":"FoBa"}
Output: 2
Explanation: FooBar and FootBall.
Example 3
Input: {"queries":["Foo"],"pattern":"F"}
Output: 1
Explanation: Insert 'oo'.

Constraints

Asked by

Google
Solve this problem in the editor →