gives correct answer for custom test cases but not upon final submission.
also, how to know if the arrangement is not possible and when to print -1.
Wrong answer upom final submission
you can check this explanation
it is actually mine, it gets submitted on leetcode as well hackerblocks, u can skip to the coding part
which begins at 13:10
and there in the end is the condition for checking the -1 condition as well
amazing explanation sir but i m still getting wrong answerupon final submission https://ide.codingblocks.com/s/243036
- number of different oranges are not n, it’s w. So change 34 to int arr[w]. Also change condition in line 35 to i<w.
- you have not check condition when arr[i-1]==-1, In that condition your dp[i][j] will be dp[i-1][j]. SO change line 18 to if(i>j || arr[i-1]==-1)
Here is the updated code. It’s working for all testcases
https://ide.codingblocks.com/s/243238
i don’t think you followed the video correctly
this is the code in it
u can see the difference in the condition for n==1
and in the loop’s of condition