Question: Write a Java Code.You are given an n*m grid which contains lower case English letters. How many times does the phrase agu appear horizontally, vertically,
Write a Java Code.You are given an n*m grid which contains lower case English letters. How many times does the phrase "agu" appear horizontally, vertically, and diagonally in the grid? The phrase "agu" must be in one of these shapes:
Input Format
First line will include two integer numbers (n and m), where n denotes the number of rows and m denotes the number of columns in the grid. Next n lines will contain a string of length m which contains lower-case English letters only
Constraints
1 <= n,m <= 10
Output Format
Your program will print the number of times the word agu appears in the grid.
Sample Input 0
5 5 coder ahmet gulay unagu songs
Sample Output 0
2
Explanation 0
coder **a**hmet **g**ulay **u**nagu songs
coder ahmet gulay un**agu** songs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
