Find if the word is present horizontally in character matrix - Java Quiz Question



Write a program to find if the word is present horizontally in a character matrix.

Input (char[][], String) Output (Boolean)
B A T C
C T O P
X Y Z W
A C W Z
search word = TOP
true
Q E A
R M I
X Y Z
search word = MAT
false
Q E A D R
B E G J I
W Z A L N
X V M S U
C J O P T
search word = EAST
false
Q E A
R M N
X Y T
search word = ANT
false
B A T C Q
T O P C X
M E R I T
A C W Z S
search word = MERIT
true

class FindWordPresentHorizontallyInCharacterMatrix

{    public static void main(String s[])
    {
        char[][] input = {{'A', 'S', 'C', 'D'}, {'C', 'A', 'T', 'F'}, {'Q', 'M', 'T', 'S'}, {'V', 'X', 'Z', 'A'}};
        System.out.println("CAT is present horizontally : " + isWordIsPresentHorizontallyInMatrix(input, "CAT"));

    }


public static boolean isWordIsPresentHorizontallyInMatrix(char[][] matrix, String searchWord) {
//Write code here to find if the word is present in the given matrix.
}
}