Official algorithmic problem description and constraints.
You are given a string π consisting of lowercase English letters.
Rearrange the characters of π to form a new string π that is not equal to π , or report that it's impossible.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.