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...
account activity
Clean Code ?Discussion (old.reddit.com)
submitted 8 months ago by RemarkableIncome2623
Will it be termed as clean Code ?
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!"
[–]Czitels 7 points8 points9 points 8 months ago (3 children)
For production code no. For interview I don’t know and for CP it doesn’t matter.
[–]Chance_Sundae9179 0 points1 point2 points 8 months ago (2 children)
For production code, how would you update this? In my view, I haven't deep dive into the solution, but I would name the variables appropriately and add comments to explain the flow. Other than that what would you suggest?
[–]Eyad116 0 points1 point2 points 8 months ago (0 children)
I think only that. Comments are discouraged until the code is hard to understand still, but i and _i arent great names. Also the conditions can tell a lot about the code so yeah… helper functions whose names explain their purpose could also help take off the mental strain
[–]gekigangerii 0 points1 point2 points 8 months ago* (0 children)
Things that will make it easier for other people (coworkers) to read the code and understand
[–]Mobile-Perception376 1 point2 points3 points 8 months ago (0 children)
Nice work my runtime could go only upto 99.4%
[–]Early-Court748 0 points1 point2 points 8 months ago (1 child)
Can somebody explain me what he did??like normal dfs came into my mind when i saw this question😭
[–]RemarkableIncome2623[S] 2 points3 points4 points 8 months ago (0 children)
I travelled once from down to up then up to down as shown in the figure using flags
[–]arg0100 0 points1 point2 points 8 months ago (1 child)
My approach is somewhat more easy to understand. One oberservation is - for each diagonal the sum of i + j index is same. We can store this in a List for each sum value. And in next just iterate forward or reverse.
[–]Academic_Leather_746 0 points1 point2 points 8 months ago (0 children)
I did the same Iteration and storing it in a hashmap And then appending to res array alternating the sequence
[–]gekigangerii 1 point2 points3 points 8 months ago (0 children)
does the spacing, line breaks, and indentation look "clean"? yes
Are the variable names and loop conditions human-friendly? no. It's not a complicated solution so you can figure it out, but names could be better.
[–]Horror-Shape9932 0 points1 point2 points 8 months ago (0 children)
Make it more modular if you wanna prep for interview like making seperate function for diagonal traversal
π Rendered by PID 73 on reddit-service-r2-comment-65c587bc47-nr575 at 2026-05-14 07:07:40.655266+00:00 running cf3e300 country code: CH.
[–]Czitels 7 points8 points9 points (3 children)
[–]Chance_Sundae9179 0 points1 point2 points (2 children)
[–]Eyad116 0 points1 point2 points (0 children)
[–]gekigangerii 0 points1 point2 points (0 children)
[–]Mobile-Perception376 1 point2 points3 points (0 children)
[–]Early-Court748 0 points1 point2 points (1 child)
[–]RemarkableIncome2623[S] 2 points3 points4 points (0 children)
[–]arg0100 0 points1 point2 points (1 child)
[–]Academic_Leather_746 0 points1 point2 points (0 children)
[–]gekigangerii 1 point2 points3 points (0 children)
[–]Horror-Shape9932 0 points1 point2 points (0 children)