Competitive - Algorithm to solve this : I tried to solve this challenge some competitive website. here is the desc:
<br><br>
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.

Complete the function maximumSuperiorCharacters which takes in an array of integers denoting the frequencies of the English letters and returns an integer denoting the maximum number of superior characters.

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 we have two es, one l, one s, and none of the other letters. We can form a string with one superior character, for example, else. One can also show that this is the maximum number of superior characters that can be present. Thus, the answer is 1. There are also many other permutations of characters possible to form a string with maximum superior characters.

Here is what i done so far

    int maximumSuperiorCharacters(int[] Q)
    {
      int R = 0;
      for (int V : Q) R += V;
      return --R / 2;
    }