Meesho Coding Question – Solved

5 Live
The city of Hackerland can be represented using a grid with n rows and m columns containing an empty cell represented by a '*' and a blocked cell represented by a #. Traveling is allowed only through empty cells. The people of Hackerland are required to travel from a starting cell defined by the character 'S' to an ending cell represented by a character 'E'. The people can jump a length of any integer k in all four directions from a given cell i.e. up, down, left, and right. However, if the jump length kis greater than 1, the next jump must be made in the same direction, For example, a hacker is allowed to jump 3 units towards the right, followed by 1 unit towards the right, and then 3 units towards the left. They however cannot jump 3 units towards the right followed by 1 unit towards the left as direction change is not allowed if the previous jump was of length greater than 1. Note that the last jump in any jump sequence is always of length 1. The jump can be made over a blocked cell as well as long as both starting and ending cells are empty. Given the map of Hackerland as a 2g matrix grid, that contains exactly one 'S' and 'E' each, find the minimum number of jumps required to travel from Sto E. Report -1 if it is not possible to reach E from S. Example Suppose n = 5, m = 6 and grid = ["S **** #". ******** ******* ******** " ***** E")

Asked in: Meesho

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |