FunctionRacerProblemsRace

Longest Pair With No Shared Letter

MediumBitsPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems