Problem 3722 · Medium
Try every prefix reversal and every suffix reversal, then keep the smallest result.
Open the interactive visualisation