767. Reorganize String

 

 

https://leetcode.com/problems/reorganize-string/solution/

 

http://www.cnblogs.com/grandyang/p/8799483.html

 

 

Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.

If possible, output any possible result.  If not possible, return the empty string.

Example 1:

Input: S = "aab"
Output: "aba"

Example 2:

Input: S = "aaab"
Output: ""

posted on 2018-11-08 16:07  猪猪🐷  阅读(91)  评论(0)    收藏  举报

导航