Grid and phrase
Practice
3.7 (43 votes)
Arrays
Brute Force search
Data structures
Easy
Multi Dimensional
Problem
94% Success 11779 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an n*m grid which contains lower case English letters. How many times does the phrase "saba" appear horizontally, vertically, and diagonally in the grid?

Input format

  • First line: Two integer n and m, where n denotes (1 <= n,m <= 100) the number of rows and m denotes the number of columns in the grid
  • Next n lines: Each line must contain a string of length m which contains lower-case English letters only

Output format

Print the number of times the word “saba” appears in the grid.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
15 votes
Tags:
ArraysData StructuresMulti-dimensional
Points:20
124 votes
Tags:
Ad-HocBasic ProgrammingEasyGeometryImplementation
Points:20
30 votes
Tags:
ArraysData StructuresEasyString Manipulation