Menu
Question Index
...


Write a program to find if the word is present in the character matrix. The directions are horizontal, vertical, upward diagonal, downward diagonal. Need not search for their opposite directions.

Input (char[][], String) Output (Boolean)
B A T C
T O P C
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
true
Q E A
R M N
X Y T
search word = ANT
true

class FindWordPresentInCharacterMatrix

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

    }


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

//Write code here if we want create any new methods.
}

Doubts

Problems

Topic: getChars() Method In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App