Reorganize String

Medium

Company Tags

You are given a string s, rearrange the characters of s so that any two adjacent characters are not the same.

You can return any possible rearrangement of s or return "" if not posssible.

Example 1:

Input: s = "axyy"

Output: "xyay"

Example 2:

Input: s = "abbccdd"

Output: "abcdbcd"

Example 3:

Input: s = "ccccd"

Output: ""

Constraints:

  • 1 <= s.length <= 500.
  • s is made up of lowercase English characters.


Company Tags

Please upgrade to NeetCode Pro to view company tags.

s =