← 返回 amazon 的题目列表Reorganize String
类型:online_judge
Given a string, return a reorganized string such that no two adjacent characters are the same. If it is not possible, return an empty string.
Input:
A string s of lowercase letters with length in the range [1, 500].
Output:
A reorganized string such that no two adjacent characters are the same.
Example 1:
Input: "aab" Output: "aba"
Example 2:
Input: "aaab" Output: ""
Note: Only lowercase alphabets are allowed.
Example
Input
"aab"