pairs. A string is a **cover** if every string from pairs occurs in it as a subsequence (its letters appear in order, though not necessarily next to each other). The **shortest covers** are the covers of the smallest possible length.
Describe each shortest cover by its letter counts: an array of 26 numbers whose i-th entry says how many times the i-th letter of the English alphabet occurs in it. Covers that differ only in the order of their letters have the same counts.
Return every distinct letter-count array of a shortest cover, in any order.pairs=["xy", "yx"] → [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0]]
The shortest covers are "xyx" and "yxy". The first has two x and one y, the second the other way round, so the letter counts differ.
pairs=["ab", "bc"] → [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
The only shortest cover is "abc", with each letter once.
pairs=["qq"] → [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
For "qq" to be a subsequence, two q letters are needed.
pairs consists of two lowercase English letterspairs are distinctpairs uses at most 16 distinct letters in totalpairs=["xy", "yx"]
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0]]
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.