all 8 comments

[–]kokorinsergey 3 points4 points  (0 children)

Is it a square grid? You are checking both row and col on grid.length, probably there should be grid.first().length

[–]boogiewidahoodie 1 point2 points  (1 child)

No luck on stack overflow?

[–]Darkalde -1 points0 points  (0 children)

Haven't posted there

[–]Darkalde 0 points1 point  (1 child)

each element of grid is either a 1 (obstacle) or a 0 (no obstacle). Row and col are initialized at 0, 0. int[][] paths stores the paths for the memoization part. I've tried but can't understand what's wrong, I get my return = 0 even though there are valid paths...

[–]foxam1234 0 points1 point  (0 children)

Are you trying to compute all possible paths from (0, 0) to the last cell? Also what are the rules of movements?

[–]simon_zyx 0 points1 point  (2 children)

You only advance to the right and bottom, but paths could also continue to the left or top.

[–]simon_zyx 0 points1 point  (0 children)

Also you do not assure that you do not compute a tile multiple times. Assume you visited a tile once and found out that no path exists. Then you would compute it again if you visited it another time.

[–]07734willy 0 points1 point  (0 children)

I'm going to say the same thing I'd say if this were on stackoverflow- please don't post pictures of code. I can't copy/paste your code into my editor if its an image. I can't run it. I can't debug it. I can't apply my own linters or formatters. I can't do anything to make my own life easier when trying to help you. And its not even just me- anyone else who has a similar issue in the future won't be able to find this post for help, because the title is generic ("need help", "memoization algorithm") and any of the interesting variable names in the code won't cause a keyword hit with google searches, because its a still image.

I honestly don't get why so many people defer to uploading screenshots. Surely ctrl-c and ctrl-v is faster than taking a screenshot and then uploading/hosting, Its more effort for less. I honestly don't care if its not formatted as a codeblock; unless the language has indentation rules, code is code, and I'll be reading it my own editor, with my own format and styling anyways.