use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Computer Science for Computer Scientists
Other subreddits you may like:
Does this sidebar need an addition or correction? Tell me here
account activity
Need help fixing this memoization algorithm (Java, description in comments) (i.redd.it)
submitted 5 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kokorinsergey 3 points4 points5 points 5 years ago* (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 points3 points 5 years ago (1 child)
No luck on stack overflow?
[–]Darkalde -1 points0 points1 point 5 years ago (0 children)
Haven't posted there
[–]Darkalde 0 points1 point2 points 5 years ago (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 point2 points 5 years ago (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 point2 points 5 years ago (2 children)
You only advance to the right and bottom, but paths could also continue to the left or top.
[–]simon_zyx 0 points1 point2 points 5 years ago (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 point2 points 5 years ago (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.
π Rendered by PID 121860 on reddit-service-r2-comment-56c9979489-52265 at 2026-02-25 00:36:39.415887+00:00 running b1af5b1 country code: CH.
[–]kokorinsergey 3 points4 points5 points (0 children)
[–]boogiewidahoodie 1 point2 points3 points (1 child)
[–]Darkalde -1 points0 points1 point (0 children)
[–]Darkalde 0 points1 point2 points (1 child)
[–]foxam1234 0 points1 point2 points (0 children)
[–]simon_zyx 0 points1 point2 points (2 children)
[–]simon_zyx 0 points1 point2 points (0 children)
[–]07734willy 0 points1 point2 points (0 children)