Grokking Meta Coding Interview

0% completed

Hidden Document
Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content

.....

.....

.....

Like the course? Get enrolled and start learning!
C

CaptainKidd

· 4 years ago

One small way to improve the answer provided in this challenge is doing away with the memory array to tell where you've been before. There's no need for it. Just mark the node as something other than 0 or 1 to mark that you've been there.

So for example mark the nodes you've visited with a value of 2 and then do a check grid[x][y] == 2 and if that's true you can return 0 in the recursive call. Saves a little time and memory.

Show 1 reply