Description
Two strings can break if one can be rearranged so it's >= other character by character. Return true if either can break the other.
Examples
Input:
s1 = "abc", s2 = "xya"Output:
trueExplanation:
abc breaks xya.
Input:
s1 = "abe", s2 = "acd"Output:
falseExplanation:
For s1 = "abe", s2 = "acd", the answer is false because the check if a string can break another string condition is not met.
Input:
s1 = "leetcode", s2 = "interview"Output:
trueExplanation:
After sorting s1 becomes "cdeeeolt" and s2 becomes "eeeiinrtv". Comparing character by character: 'c'≥'e' is false, but 'e'≥'e', 'e'≥'e', 'e'≥'i', 'e'≥'i', 'o'≥'n', 'l'≥'r', 't'≥'t', 'v' has no pair. Since s2 can break s1 (each character in sorted s2 is ≥ corresponding character in sorted s1), the answer is true.
Constraints
- •
1 ≤ s1.length ≤ 10⁵