3

PROBLEM OF THE DAY: 23/08/2023 | Find the string in grid

 1 year ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-23082023-find-the-string-in-grid/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PROBLEM OF THE DAY: 23/08/2023

August 24, 2023 |10 Views
PROBLEM OF THE DAY: 23/08/2023 | Find the string in grid
Problem of the Day, matrix, Data Structure and Algorithm
 Save  Share   Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Matrix but will also help you build up problem-solving skills

In this problem, we are given a 2D grid of n*m of characters and a word. Our task is to find all occurrences of a given word in a grid. A word can be matched in all 8 directions at any point. Word is said to be found in a direction if all characters match in this direction (not in zig-zag form). The 8 directions are, horizontally left, horizontally right, vertically up, vertically down, and 4 diagonal directions.

Note: The returning list should be lexicographically smallest. If the word can be found in multiple directions starting from the same coordinates, the list should contain the coordinates only once.

Example :

Input: 
grid = {{a,b,c},{d,r,f},{g,h,i}},
word = "abc"
Output: 
{{0,0}}

Explanation: 
From (0,0) we can find "abc" in horizontal right direction.

Give the problem a try before going through the video. All the best!!!

Problem Link:  https://practice.geeksforgeeks.org/problems/find-the-string-in-grid0111/1

Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp14-compiler/8f5ac30d-0175-473f-bf22-c2f6976a1f5a

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK