first and second of equal length, made of lowercase English letters.
Say that word x *outranks* word y if at every position i the letter x[i] comes no earlier in the alphabet than y[i] (equal letters are fine).
You may rearrange the letters inside each word however you like. Return True if some rearrangement makes one of the words (either one) outrank the other, and False otherwise.first="cat", second="dog" → False
Sort both: "act" and "dgo". a ≤ d and c ≤ g, but t > o, so neither word can beat the other in every position.
first="bee", second="ace" → True
Sorted they are "bee" and "ace": b ≥ a, e ≥ c, e ≥ e, so first outranks second.
first="zz", second="zz" → True
first="cat", second="dog"
False
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.