Camelcase Matching - Problem
Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.
A query word queries[i] matches pattern if you can insert lowercase English letters into the pattern so that it equals the query. You may insert a character at any position in pattern or you may choose not to insert any characters at all.
Input & Output
Example 1 — Basic Matching
$
Input:
queries = ["ForceFeedBack","ForYou","Fun"], pattern = "FB"
›
Output:
[true,false,false]
💡 Note:
ForceFeedBack can be formed by inserting lowercase letters into FB (F+orce+B+ack). ForYou cannot because it has Y (uppercase) not in pattern. Fun cannot because it lacks B.
Example 2 — Exact Match
$
Input:
queries = ["CompetitiveProgramming","FaceBook"], pattern = "CamelCase"
›
Output:
[false,false]
💡 Note:
CompetitiveProgramming has P (uppercase) not in pattern. FaceBook has uppercase letters F,B that don't match pattern CamelCase.
Example 3 — Edge Case
$
Input:
queries = ["AA","aaa"], pattern = "AAA"
›
Output:
[false,false]
💡 Note:
AA is missing one A from pattern AAA. aaa has all lowercase but pattern requires uppercase A's.
Constraints
- 1 ≤ queries.length ≤ 100
- 1 ≤ queries[i].length ≤ 100
- 1 ≤ pattern.length ≤ 100
- queries[i] and pattern consist of English letters
Visualization
Tap to expand
Understanding the Visualization
1
Input
Array of query strings and a pattern string
2
Process
Check if each query can be formed by inserting lowercase letters into pattern
3
Output
Boolean array indicating which queries match
Key Takeaway
🎯 Key Insight: Uppercase letters form the skeleton that must match exactly, while lowercase letters are just filler that can be inserted anywhere
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code