Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ninjaAndHisFriends.cpp created #131

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

Merged
codewithdev merged 3 commits into codewithdev:master from thisabhijeet:ninjaAndHisFriends
Oct 6, 2022
Merged

ninjaAndHisFriends.cpp created #131

codewithdev merged 3 commits into codewithdev:master from thisabhijeet:ninjaAndHisFriends
Oct 6, 2022

Conversation

Copy link
Contributor

@thisabhijeet thisabhijeet commented Oct 5, 2022
edited
Loading

What's being changed:

ninjaAndHisFriends.cpp created

Checkoff the following:

  • Read Contribution.md
  • Created a new branch before committing.
  • My File doesn't contain any duplicacy or misinformation (isn't available in the library).
  • Added to the right category.
  • Added "add code" label.
  • Described what's being changed.

@@ -0,0 +1,125 @@
// Problem(3-D DP) : We are given an ‘N *M’ matrix.Every cell of the matrix has some chocolates on it, mat[i][j] gives us the
// number of chocolates.We have two friends ‘Alice’ and ‘Bob’.initially, Alice is standing on the cell(0, 0) and Bob is standing
// on the cell(0, M - 1).Both of them can move only to the cells below them in these three directions : to the bottom cell(↓),
Copy link
Owner

@codewithdev codewithdev Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put the problem statement in one line? (instead of) multiple lines?


int maximumChocolates(int r, int c, vector<vector<int>> &grid)
{
vector<vector<vector<int>>> dp(r, vector<vector<int>>(c, vector<int>(c)));
Copy link
Owner

@codewithdev codewithdev Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add inline comment for the code snippet.

Copy link
Owner

@codewithdev codewithdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @thisabhijeet for your contribution 🎉 . I left a few comments for you to address before this PR gets merged.

Copy link
Contributor Author

thanks a lot for reviewing this PR! changes have been made!

// from that cell with them. It can happen that they visit the same cell, in that case, the chocolates need to be considered only
// once. They cannot go out of the boundary of the given matrix, we need to return the maximum number of chocolates that Bob and
// Alice can together collect.
// Problem(3-D DP) : https://www.codingninjas.com/codestudio/problems/ninja-and-his-friends_3125885
Copy link
Owner

@codewithdev codewithdev Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Problem(3-D DP) :

// We are given an ‘N *M’ matrix.Every cell of the matrix has some chocolates on it, mat[i][j] gives us the number of chocolates.We have two friends ‘Alice’ and ‘Bob’.initially, Alice is standing on the cell(0, 0) and Bob is standing on the cell(0, M - 1).Both of them can move only to the cells below them in these three directions: to the bottom cell(↓), to the bottom-right cell(↘), or to the bottom-left cell(↙). // When Alica and Bob visit a cell, they take all the chocolates from that cell with them. It can happen that they visit the same cell, in that case, the chocolates need to be considered only once. They cannot go out of the boundary of the given matrix, we need to return the maximum number of chocolates that Bob and Alice can together collect.

@codewithdev codewithdev merged commit 550403b into codewithdev:master Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@codewithdev codewithdev codewithdev approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /