Reorganize String
Signals to notice
Brute force first
Try all permutations. Factorial. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Max-heap of (frequency, character). Always place the most frequent character that isn't the same as the last placed. Once you hold onto the right piece of information from moment to moment, the problem feels less like trial and error and more like following a shape that was there all along.
What must stay true
If the most frequent character appears more than (n+1)/2 times, rearrangement is impossible. Otherwise, alternating the two most frequent characters always works. When you keep that truth intact, each local choice supports the larger solution instead of fighting it.
Easy way to go wrong
Not checking feasibility first — if any character has frequency > (n+1)/2, return empty string immediately. The fix is usually to return to the meaning of each move, not just the steps themselves.