Skip to content

Conversation

@thisabhijeet
Copy link
Contributor

@thisabhijeet thisabhijeet commented Oct 5, 2022

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

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

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.

@thisabhijeet
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

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

Labels

None yet

2 participants