Best-matching binary pattern with wildcards

0
Remix

You get a list of patterns over 0, 1 and a wildcard that matches either bit, and a query string of bits. Return the pattern that matches the query best. Agree on what "best" means with the interviewer (for example, the fewest wildcards), and make lookups faster than checking every pattern.

GoogleCodingLast asked Jan 2026
No answer yet. Write the first one; the best answer gets endorsed.