Longest Pair With No Shared Letter
Choose two words a and b from different positions of words that have no letter in common. Return the largest possible value of len(a) * len(b), or 0 if every pair of words shares a letter.
Example 1
words ["bike","sun","moon","desk"]
returns 16
bike and moon share no letter: 4 * 4 = 16. So do moon and desk. Every other pair shares a letter or is shorter.
Example 2
words ["a","aa","aaa"]
returns 0
All three words hold the letter a.
Constraints
2 <= len(words) <= 1001 <= len(words[i]) <= 20- the words hold lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Bits problems
- Next Gray CodeMedium
- Subsets With a Target XORMedium
- The One Not TripledMedium
- Two Unpaired NumbersMedium
- Undo the XOR ChainMedium
- Well-Formed Byte StreamMedium
- A Different Hat for EveryoneHard
- Erase Until the XOR Is ZeroHard