I don't understand where is the mistake. Can you tell me where is the mistake?
public class FindtheMissingLetter {
public static char findMissingLetter(char[] array)
{
char letter;
for(int i=0;i<array.length;i++)
{
if(array[i]==array[i-1]+2)
{
letter=(char) (array[i-1]+1);
return letter;
}
}
return ' ';
}
}
You need to think about the logic and work out the math for each pass of the loop. Look at the line:
and think about what the value would be for each iteration of your loop.
The best way to do this is to create a small char[] (say 3 letters) and do it by hand using your algorithm. If you do that, you should easily see your error.