Tap here to switch tabs
Problem
Submissions

Problem: Reformat The String

med
30 min
Try to solve the Reformat The String problem.

Statement

You are given an alphanumeric string s consisting of lowercase English letters and digits.

Rearrange the characters of s such that no two adjacent characters have the same type, meaning no two letters are adjacent and no two digits are adjacent.

Return the reformatted string. If it is impossible to reorder the characters to satisfy this condition, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters and digits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reformat The String

med
30 min
Try to solve the Reformat The String problem.

Statement

You are given an alphanumeric string s consisting of lowercase English letters and digits.

Rearrange the characters of s such that no two adjacent characters have the same type, meaning no two letters are adjacent and no two digits are adjacent.

Return the reformatted string. If it is impossible to reorder the characters to satisfy this condition, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters and digits.