This is the only solution that explains every piece of the puzzle in a crystal clear way.Thanks a lot
@duanebuell7055 Жыл бұрын
Ok i read several discussion posts and wasnt getting how the prefix sum works, but 7 minutes into your video and i think i get it and even the mod part that you haven't gotten to yet. I'll try to code it tomorrow before watching the rest! Thank you so much for this video!
@venugopalreddy8596 Жыл бұрын
Great Explanation. Thank you!!
@vibhavdubey9060 Жыл бұрын
Amazing bro!!
@ankitsaini3421 Жыл бұрын
how it is n^1/2 for n
@codingmohan Жыл бұрын
It is a mathematical problem of maximizarion (remember differentiation :D) For N < k as well, we have N/k × k×k. Note that the two expressions are inversely proportional i.e. 1. if the value of k is too small the second one in the expression will be negligible 2. If the value of k is closer to N then the first one becomes negligible. Note that in both the scenarios, the final complexity will be well under limit (again assuming k is larger). To make both expressions significant, you can put the value of k as sqrt(N). In that case the expression will be maximized and that is also well under the limits. How to come up with sqrt(N)? -- differentiation could be a way :)
@josephaj8310 Жыл бұрын
Amazing bro, next time teach us number theory involved in coding too
@DeepakKumar-ej3wm Жыл бұрын
Please upload yesterday's biweekly contest's 4th question solution. Only few people did it and it was a good question I guess. Waiting for its video
@codingmohan Жыл бұрын
Disclaimer - It is "really" hard and need patience :) Here you go - kzbin.info/www/bejne/eXewan6kiLGEo5Y
@CodingJoySoul Жыл бұрын
Bhaiya, agar aapke new year se pehle 5k subscribers karadiye to kya aap saara Leetcode solve kardoge... I mean solution videos for every Leetcode DSA Question?
@idiot3641 Жыл бұрын
Pagal wagal hai keya😂
@codingmohan Жыл бұрын
:D It is not possible for me to upload all the problems of leetcode because I do this only over weekends (and KZbin just pays me 6-7$ a month as of today :P). It is impractical as well in my opinion. You should practice to build the thought process and not to expect an exact same problem in next contest :(
@souravjoshi2293 Жыл бұрын
At 38:12 , Line no.80 - what is the need to find diff ? And diff = (i - arr[0]) ? Can you please explain this line. In your explanation, you just created a k sized array and incremented by taking modulo with k.
@MohitSharma-jy1bc11 ай бұрын
same question, why did you find diff?
@AnandKumar-kz3ls Жыл бұрын
hi mohan how your code is handling the cases where valid the subarray starts with the 0th index
@codingmohan Жыл бұрын
Notice that the prefix array is 1 indexed and the loop below that runs from 0 to N. All the subarrays starting from 0 in the original array will start at 1 in the new array.
@AnandKumar-kz3ls11 ай бұрын
@@codingmohan Oh ok got it if possible try to make video on 2nd question of last weekly contest will be very helpfull
@souravjoshi2293 Жыл бұрын
Didn't understand approach-1 😞
@codingmohan Жыл бұрын
Try watching it one more time. Let me know which part you are facing issues with and maybe I can throw some more light. The crux is to separate I and J. That is not possible if we can't remove the square (otherwise we can never avoid i×j part from the equation which is not possible to separate).