You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Dynamic_Programming/README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,12 +114,22 @@
114
114
Output: 4
115
115
Explanation: Total length is 4, and the cut lengths are 2, 1 and 1. We can make maximum 4 segments each of length 1.
116
116
117
+
## 15. Longest Path in Matrix:
118
+
Given a n*n matrix where all numbers are distinct, find the maximum length path (starting from any cell) such that all cells along the path are in increasing order with a difference of 1.
119
+
We can move in 4 directions from a given cell (i, j), i.e., we can move to (i+1, j) or (i, j+1) or (i-1, j) or (i, j-1) with the condition that the adjacent cells have a difference of 1.
120
+
Example 1:
121
+
Input: mat[][] = {{1, 2, 9}
122
+
{5, 3, 8}
123
+
{4, 6, 7}}
124
+
Output: 4
125
+
The longest path is 6-7-8-9.
117
126
## 16. Minimum Sum Partition:
118
127
Given an integer array arr of size N, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum and find the minimum difference
119
128
Example 1:
120
129
Input: N = 4, arr[] = {1, 6, 11, 5}
121
130
Output: 1
122
131
Explanation: Subset1 = {1, 5, 6}, sum of Subset1 = 12 Subset2 = {11}, sum of Subset2 = 11
132
+
123
133
## 17. Count Number of Hops:
124
134
A frog jumps either 1, 2, or 3 steps to go to the top. In how many ways can it reach the top. As the answer will be large find the answer modulo 1000000007.
0 commit comments