1417. Reformat The String
https://leetcode.com/problems/reformat-the-string/
Given 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.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
重组str使得字母和数字相隔,不能满足的话返回空。将数字和字符分别抽出放到两个list里,从长的开始轮流抽。
Last updated
Was this helpful?