Tap here to switch tabs
Problem
Submissions

Problem: Change Min Characters to Meet One of Three Conditions

Try to solve the Change Minimum Characters to Satisfy One of Three Conditions problem.

Statement

Given two strings a and b. In one operation, you can change any character in a or b to any lowercase English letter.

Return the minimum number of operations required to satisfy at least one of the following three conditions:

11. Every letter in a is strictly smaller in alphabetical order than every letter in b.
22. Every letter in b is strictly smaller in alphabetical order than every letter in a.
33. Both a and b consist of only one distinct letter (the exact same letter across all characters in both strings).

Constraints:

  • 1≤1 \leq a.length, b.length ≤105\leq 10^5

  • a and b consist only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Change Min Characters to Meet One of Three Conditions

Try to solve the Change Minimum Characters to Satisfy One of Three Conditions problem.

Statement

Given two strings a and b. In one operation, you can change any character in a or b to any lowercase English letter.

Return the minimum number of operations required to satisfy at least one of the following three conditions:

11. Every letter in a is strictly smaller in alphabetical order than every letter in b.
22. Every letter in b is strictly smaller in alphabetical order than every letter in a.
33. Both a and b consist of only one distinct letter (the exact same letter across all characters in both strings).

Constraints:

  • 1≤1 \leq a.length, b.length ≤105\leq 10^5

  • a and b consist only of lowercase English letters.