Given an input string, the algorithm finds the most beautiful string from that input