Skip to content

Practice Check If a String Can Break Another String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1433
LeetCode Problem

Check If a String Can Break Another String

Problem Statement

Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa. A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.

Source: Check If a String Can Break Another String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s1 = "abc", s2 = "xya"
Output
true

# Example 2

Input
s1 = "abe", s2 = "acd"
Output
false

# Example 3

Input
s1 = "leetcodee", s2 = "interview"
Output
true

Constraints

s1.length == n
s2.length == n
1 <= n <= 10^5
All strings consist of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Check If a String Can Break Another String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.