Reformat The String Problem
Reformat The String Problem — ExecCode Easy DSA Practice
Solve the Reformat The String problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an alphanumeric string s. Your task is to 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. (Alphanumeric string is a string consisting of lowercase English letters and digits). 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.
Examples
Input {"s": "a0b1c2"}; Output 0a1b2c. Input {"s": "leetcode"}; Output
Constraints
1 <= s.length <= 500 s consists of only lowercase English letters and/or digits.
Practice Reformat The String free on ExecCode. Browse DSA problems, topic map, and placement guides.