Composite index prefix match

Write codeEasy14 minSnowflake and Oracle style

Your task

An orders table carries one composite index and the planner has to decide how much of it each query can use. index_columns lists the index columns in index order, outermost first, for example region then tier then created_at. Each entry of queries is the set of columns that query pins with an equality predicate, written as names joined by commas, for example "region,tier". Order inside a query carries no meaning because equality predicates commute, a name may repeat, and a name that is not an index column is ignored. The planner starts at the first index column and keeps going while the next index column is pinned. It stops at the first index column the query leaves unpinned, even when columns after that one are pinned. Return, for each query in order, how many leading index columns it can use.

Examples

usable_index_prefix(index_columns: list[str], queries: list[str]) -> list[int]
Example 1
Inputusable_index_prefix(["region", "tier", "created_at"], ["region,tier", "tier", "region,created_at", ""])
Output[2, 0, 1, 0]
Example 2
Inputusable_index_prefix(["a", "b", "c"], ["c,b,a", "b,a"])
Output[3, 2]
Example 3
Inputusable_index_prefix(["dept"], ["dept,dept", "status"])
Output[1, 0]