From ca86e3a228f19b8e01ce5a44128108008b48af3d Mon Sep 17 00:00:00 2001
From: Harsh A Dubey <107762558+1032210414@users.noreply.github.com>
Date: Sun, 11 Feb 2024 12:50:15 +0530
Subject: [PATCH 1/2] Create 1463. Cherry Pickup II.cpp

In this, I solved leet code  todays problem that Cherry-pickup-2.
---
 cpp/1463. Cherry Pickup II.cpp | 59 ++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 cpp/1463. Cherry Pickup II.cpp

diff --git a/cpp/1463. Cherry Pickup II.cpp b/cpp/1463. Cherry Pickup II.cpp
new file mode 100644
index 000000000..4d7fa496c
--- /dev/null
+++ b/cpp/1463. Cherry Pickup II.cpp	
@@ -0,0 +1,59 @@
+//   https://leetcode.com/problems/cherry-pickup-ii/
+
+
+// You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.
+
+// You have two robots that can collect cherries for you:
+
+// Robot #1 is located at the top-left corner (0, 0), and
+// Robot #2 is located at the top-right corner (0, cols - 1).
+// Return the maximum number of cherries collection using both robots by following the rules below:
+
+// From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).
+// When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
+// When both robots stay in the same cell, only one takes the cherries.
+// Both robots cannot move outside of the grid at any moment.
+// Both robots should reach the bottom row in grid.
+
+
+Solution:
+
+#include <vector>
+#include <algorithm>
+
+using namespace std;
+
+class Solution {
+public:
+    int cherryPickup(vector<vector<int>>& grid) {
+        int rows = grid.size();
+        int cols = grid[0].size();
+
+        vector<vector<vector<int>>> dp(rows, vector<vector<int>>(cols, vector<int>(cols, 0)));
+
+        for (int i = rows - 1; i >= 0; --i) {
+            for (int j = 0; j < cols; ++j) {
+                for (int k = 0; k < cols; ++k) {
+                    int cherries = grid[i][j] + (j != k ? grid[i][k] : 0);
+                    if (i == rows - 1) {
+                        dp[i][j][k] = cherries;
+                    } else {
+                        int maxCherries = 0;
+                        for (int dj = -1; dj <= 1; ++dj) {
+                            for (int dk = -1; dk <= 1; ++dk) {
+                                int nj = j + dj;
+                                int nk = k + dk;
+                                if (nj >= 0 && nj < cols && nk >= 0 && nk < cols) {
+                                    maxCherries = max(maxCherries, dp[i + 1][nj][nk]);
+                                }
+                            }
+                        }
+                        dp[i][j][k] = cherries + maxCherries;
+                    }
+                }
+            }
+        }
+        
+        return dp[0][0][cols - 1];
+    }
+};

From 6c92efe64c8f86620f5261ea02b87e863e8b7f72 Mon Sep 17 00:00:00 2001
From: Yaseen Khan <kyaseen49@yahoo.com>
Date: Wed, 6 Nov 2024 21:18:16 -0700
Subject: [PATCH 2/2] Fixed file name and removed question description

---
 ...ickup II.cpp => 1463-cherry-pickup-ii.cpp} | 20 -------------------
 1 file changed, 20 deletions(-)
 rename cpp/{1463. Cherry Pickup II.cpp => 1463-cherry-pickup-ii.cpp} (59%)

diff --git a/cpp/1463. Cherry Pickup II.cpp b/cpp/1463-cherry-pickup-ii.cpp
similarity index 59%
rename from cpp/1463. Cherry Pickup II.cpp
rename to cpp/1463-cherry-pickup-ii.cpp
index 4d7fa496c..b7b9d5fff 100644
--- a/cpp/1463. Cherry Pickup II.cpp	
+++ b/cpp/1463-cherry-pickup-ii.cpp
@@ -1,23 +1,3 @@
-//   https://leetcode.com/problems/cherry-pickup-ii/
-
-
-// You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.
-
-// You have two robots that can collect cherries for you:
-
-// Robot #1 is located at the top-left corner (0, 0), and
-// Robot #2 is located at the top-right corner (0, cols - 1).
-// Return the maximum number of cherries collection using both robots by following the rules below:
-
-// From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).
-// When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
-// When both robots stay in the same cell, only one takes the cherries.
-// Both robots cannot move outside of the grid at any moment.
-// Both robots should reach the bottom row in grid.
-
-
-Solution:
-
 #include <vector>
 #include <algorithm>
 
