Menu
Question Index
...


Write a program to find if the word is present diagonally in character matrix. It can be either upward diagonal or downward diagonal.

Input (char[][], String) Output (Boolean)
B A T C
T O P C
X Y O W
A C T Z
search word = TOP
false
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
R E A
R A N
X Y T
search word = RAT
true
B A T C Q
T O P C X
M E R I T
A C W Z S
search word = MERIT
false
B A T C Q
T O P C T
M E R I X
A C W Z S
search word = WIT
true

class FindWordPresentDiagonallyInCharacterMatrix

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

    }


public static boolean isWordPresentDiagonallyInMatrix(char[][] matrix, String searchWord) {
//Write code here to find if the word is present diagonally 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