Find remaining letter after striking out - Java Quiz Question



Write a program to find remaining letter after striking out the letters by counting 1, 2, 3 etc. As shown for GOOGLE below, O is first cancelled out since it is 2nd (1 + 1) letter from beginning, followed by L which is the 3rd letter (2 + 1) from O, followed by G which is the fourth letter (3 + 1) from L and so on. Return the last remaining letter.

Input (Character array) Output (Character)
['G', 'O', 'O', 'G', 'L', 'E'] G*OGLE
G*OG*E
G*O**E
**O**E
***O***
Output = O
['E', 'D', 'U', 'C', 'A', 'T', 'I', 'O', 'N'] T
['F', 'A', 'C', 'E', 'B', 'O', 'O', 'K'] O
['M', 'E', 'R', 'I', 'T', 'C', 'A', 'M', 'P', 'U', 'S'] A

class FindRemainingLetterAfterStrikingOut

{    public static void main(String s[])
    {
        char input[] = {'G', 'O', 'O', 'G', 'L', 'E'};
        System.out.println("The remaining letter is : " + getRemainingLetter(input));

    }


public static char getRemainingLetter(char[] input) {
//Write a code here to get the remaining letter after striking out.
}
}