Maximum Strength of K Disjoint Subarrays (Leetcode Weekly 388)
Watch in 1.5X
Here I have provided the solution and explanation of the 4th problem of Leetcode Weekly 388
Code: leetcode.com/contest/weekly-c...
#leetcode #Leetcode #Weekly #programming #cp #codechef #codeforces
Пікірлер: 6
Hey I am beginner with dp, please help me with a doubt in the for loop, what you declared by dp[i][j][0] = dp[i][j][1] = -1; ? why we are doing this?
@soumyabhattacharjee1051
3 ай бұрын
Its just initialization, for memorizing we are initializing all the dp values as -1. You can think about the state(i,p,flag) is not visited if dp[i][p][flag]==-1 Please like and subscribe if you find this helpful
Bhaiya i thought to use mcm based approach and using prefix sum bcs mine dp(i j k ) which defines as current index start of the subarray and end of the subarray and k value Using this i would get the size of mine subarray but dye to constraint i wouldn't be able to code If such situations would come Is mine idea is correct or not please response
@soumyabhattacharjee1051
3 ай бұрын
Yes the approach is correct but O(n^3), so it will pass if n
Ajke Ghum ta ektu besi hoe gechilo😢
@soumyabhattacharjee1051
3 ай бұрын
🤣