[Challenge] Superior Character
Given a string, a character is said to be superior if it has two neighboring letters that are strictly smaller than itself. We compare characters by their location in the alphabet. More formally, we say that the character at the ith position is superior if a character exists at the (i+1)th position and (i-1)th position, and the character at the ith position is strictly greater than the character at both (i+1)thand (i-1)th positions. Given the frequencies of the lowercase English letters, form a string using all these characters, such that the resultant string has the maximum number of superior characters. You need to print the maximum number of superior characters. Test : 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 output is 1 1 2 2 3 4 0 3 4 4 1 3 1 4 4 1 0 0 0 0 0 4 2 3 2 2 1 output is 25 1 1 3 3 1 1 4 4 3 1 3 3 3 0 1 2 0 4 2 1 3 0 3 1 1 1 output 24 3 3 0 2 2 2 4 1 2 1 1 1 3 3 0 0 3 2 2 4 1 4 4 1 2 1 output 25 2 1 4 1 0 2 0 3 1 2 0 3 1 1 2 0 1 4 2 3 2 3 2 0 2 1 output 21