A file finder shows UserProfileCard.tsx when you type upc, because the letters u, p, c appear in that order in the name, with gaps allowed.
Write fits(query, name) that returns true if every character of query appears in name in the same order, ignoring upper and lower case, and false otherwise. An empty query fits every name.
Input: query = "upc", name = "UserProfileCard.tsx" Output: true
U, then P, then C, in order.
Input: query = "cpu", name = "UserProfileCard.tsx" Output: false
There is a c and a p, but no u after them in that order.
0 <= query.length <= 1000 <= name.length <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #716 Does the Query Fit?. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.