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:
Both strings are sorted to find the optimal arrangement. Sorted "abc" is "abc" and sorted "xya" is "axy". Comparing character by character: 'a'<='a', 'b'<='x', 'c'<='y' - all characters in sorted s1 are <= corresponding characters in sorted s2, so s2 can break s1.
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:
falseExplanation:
After sorting both strings, neither string is greater than or equal to the other at every position, so neither can break the other.
Constraints
- •
1 ≤ s1.length ≤ 10⁵