Back to problems

Can a target string be formed using double-sided letter cards (each card used at most once)?

Algorithm · Snapchat · Medium

You receive cards, a collection of two-sided cards; each face displays one lowercase English character. For instance, a card set could be written as cards = [["m","n"], ["p","q"]]. Rules: No card may contribute more than one character. For any selected card, either of its two letters may be chosen. For a given string target, decide whether its letters can be produced with every character coming from a different card. Example cards = [["m","n"], ["p","q"]] target = "mp" ->…

Checking your access…