Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 424 Bytes

leetcode-767.md

File metadata and controls

19 lines (13 loc) · 424 Bytes
date 2024-08-10

Leetcode 767. Reorganize String

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

Return any possible rearrangement of s or return "" if not possible.

Backtracking

Keeping a map of char frequency. Recursively select chars to construct the answer, return early if one of the solution is found.

Java Code