-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Adding dynamic programming solution for unique paths problem #2992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @Panquesito7 @realstealthninja
I’ve added the Unique Paths solution with both memoization and tabulation, including self-tests. Could you please review when you get a chance? Thanks!
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is bad design, the user should not have to worry about supplying a memoization table, This is design details that should be handled internally
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests only test the tabular form and not the memoized form
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be turned into a class? with a private member of dp, and multiple behaviours, solvetabular() or solvememoised()
Hi @realstealthninja, I've made the requested changes. Could you please review again ? Thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add a brief comparison between memoization and tabulation?
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oslve mem isnt used anywhere why not replace the uniqupath memo function definitino with the one with solvemem and remove solvemem entirely?
@realstealthninja Could you please review the latest changes and let me know if everything looks fine? Thanks for your time!
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable name is too short, its nondescript/confusing. maybe rename it to memoization_table or something similar
dynamic_programming/unique_paths.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could do the same thing for this function as well
@realstealthninja Done
Added Unique Paths algorithm using Dynamic Programming (unique_paths.cpp) with both memoization and tabulation approaches. Includes self-tests with assert().
Type of Change
• New feature
Tests
• Verified with multiple test cases (3x7, 3x2, 1x1, 2x2)
• All tests passed
Checklist
• Code compiles locally
• Tests included and passing
• Naming conventions followed
• Doxygen-style comments added