Maximum Possible Value | Problem Of The Day | Mathematical

preview_player
Показать описание


Hello Guys !!
The problem that I've solved today is "Maximum Possible Value".
Do watch the full video and don't forget to hit the like button if you like the video.

Here are the Timestamps:

0:00 Problem Discussion
03:48 Intuition and Approach
11:00 Code Explained

Hashtags:
#geeksforgeeks #placement #problemoftheday #arrays #java #javascript #solved #leetcodequestionandanswers
#gfg #coding #leetcode #leetcodequestionandanswers #engineering #computerscience #artificialintelligence #problemoftheday #problemsolving #solution #solutions #hit #like #subscribe #share
Рекомендации по теме
Комментарии
Автор

bro I thought this question as subset problem.
My approach:

private static long maxPossibleValueUtil(int n, int[] a, int[] b, int i, long[] dp) {
if(i < 0) return 0;
if(b[i] < 2) return 0;
if(dp[i] != -1) return dp[i];
long pick = 0;
if(b[i] >= 2){
b[i] = b[i]-2;
pick = a[i]*2 + maxPossibleValueUtil(n, a, b, i, dp);

}
long not_pick = maxPossibleValueUtil(n, a, b, i-1, dp);

return dp[i] = Math.max(pick, not_pick);
}

Abhijeet-stbj