if jd.length=6 and days=2, then the for loop will goes up to 6-2+1. so, 0 to less then 3. then the last three values would not be taken,but the given total days is 2 only. can u explain this?
@@David-mk8kh I have learnt basics of DP from those videos, he explained them gradually building concepts, that was only thing i referred to learn and then i just practiced problems with the help of this channel.
//Recursive solution With Memoization public int f(int[] jobDifficulty,int i, int d, int max, Integer [][] dp) { if(i==jobDifficulty.length && d==0){ return 0; } if(i==jobDifficulty.length || d==0){ return (int)10e4+1; } if(dp[i][d][max]!=null) return dp[i][d][max]; max = Math.max(max, jobDifficulty[i]); //options to explore ways int way1 = max + f(jobDifficulty, i+1, d-1 ,0 , dp); //we are done on d day so move on to next day but we have to add max which we were maitaining
int way2 = f(jobDifficulty, i+1, d, max, dp); //be on the same day and we are maitaining max return dp[i][d][max] = Math.min(way1,way2); }
If there was recursion tree included in the video it would have been great to understand it easily
if jd.length=6 and days=2, then the for loop will goes up to 6-2+1. so, 0 to less then 3. then the last three values would not be taken,but the given total days is 2 only. can u explain this?
can we say this is based on DP on partitions ??
The time complexity would be O(n^2 * d) right ?
is this the latest look of leetcode for only mac os?
is this question an example of matrix chain multiplication or partition dp?
i think partition dp
what is the time and space complexity of this approach
godly solution.
what is the time and space complexity
Very Good Explanation sir 😁
bhaiya u r consistancy become my consistancy!! thank u so much🙃🙂
Hi , can you suggest me from where can I lean DSA. I didn't understand the solution in the video, I am a beginner.
@@David-mk8kh is you understand hindi there a DP series by Aditya Verma, that makes dp easy to understand
@@santoshvarma996 yes I will go through it . Thank you. Plz mention any other sources from which you prepared, if any? It will really help
@@David-mk8kh I have learnt basics of DP from those videos, he explained them gradually building concepts, that was only thing i referred to learn and then i just practiced problems with the help of this channel.
this solution is little difficult to understand , so i have given my solution may be it is helpful and understandable by others
//Recursive solution With Memoization
public int f(int[] jobDifficulty,int i, int d, int max, Integer [][] dp) {
if(i==jobDifficulty.length && d==0){
return 0;
}
if(i==jobDifficulty.length || d==0){
return (int)10e4+1;
}
if(dp[i][d][max]!=null) return dp[i][d][max];
max = Math.max(max, jobDifficulty[i]);
//options to explore ways
int way1 = max + f(jobDifficulty, i+1, d-1 ,0 , dp);
//we are done on d day so move on to next day but we have to add max which we were maitaining
int way2 = f(jobDifficulty, i+1, d, max, dp);
//be on the same day and we are maitaining max
return dp[i][d][max] = Math.min(way1,way2);
}
@@harshalyallewar Bottom up Dp for reference ->
int minDifficulty(vector&difficulty, int d) {
int n = difficulty.size();
if(d > n)
return -1;
vectordp(n + 1, vector(d + 1, 1e8));
dp[n][0] = 0;
for(int i = n - 1; i >= 0; i--){
for(int day = 0; day = 0)
dp[i][day] = min(dp[i][day], dp[j + 1][day - 1] + mx);
}
}
}
return dp[0][d];
}
@@ITACHIUCHIHA-dr8sz nice
10:32 Is there any extension that changes leetcode UI?
It’s the new update on leetcode
@@cutieenushkiee1169 I guess not everyone is getting the update?
dude u r just reading code , WHY U R IN SO HURRY
the code is easy to understand once the intuition is clear imo
@@nishankpriydarshi3984 why the loop is running till