Practice Reformat The String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type. Return the reformatted string or return an empty string if it is impossible to reformat the string.
Source: Reformat The String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "a0b1c2"
"0a1b2c"
# Example 2
s = "leetcode"
""
# Example 3
s = "1229857369"
""
Constraints
Related LeetCode Problems
Practice more problems similar to Reformat The String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.