2949. Count Beautiful Substrings II | Weekly Leetcode 373

  Рет қаралды 1,727

codingMohan

codingMohan

Күн бұрын

Пікірлер: 19
@miketsubasa3611
@miketsubasa3611 7 ай бұрын
This is the only solution that explains every piece of the puzzle in a crystal clear way.Thanks a lot
@duanebuell7055
@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
@venugopalreddy8596 Жыл бұрын
Great Explanation. Thank you!!
@vibhavdubey9060
@vibhavdubey9060 Жыл бұрын
Amazing bro!!
@ankitsaini3421
@ankitsaini3421 Жыл бұрын
how it is n^1/2 for n
@codingmohan
@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
@josephaj8310 Жыл бұрын
Amazing bro, next time teach us number theory involved in coding too
@DeepakKumar-ej3wm
@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
@codingmohan Жыл бұрын
Disclaimer - It is "really" hard and need patience :) Here you go - kzbin.info/www/bejne/eXewan6kiLGEo5Y
@CodingJoySoul
@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
@idiot3641 Жыл бұрын
Pagal wagal hai keya😂
@codingmohan
@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
@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-jy1bc
@MohitSharma-jy1bc 11 ай бұрын
same question, why did you find diff?
@AnandKumar-kz3ls
@AnandKumar-kz3ls Жыл бұрын
hi mohan how your code is handling the cases where valid the subarray starts with the 0th index
@codingmohan
@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-kz3ls
@AnandKumar-kz3ls 11 ай бұрын
@@codingmohan Oh ok got it if possible try to make video on 2nd question of last weekly contest will be very helpfull
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Didn't understand approach-1 😞
@codingmohan
@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).
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
3251. Find the Count of Monotonic Pairs II | Weekly Leetcode 410
33:04
3219. Minimum Cost for Cutting Cake II | Weekly Leetcode 406
1:03:26
3276. Select Cells in Grid With Maximum Score | Weekly Leetcode 413
36:39
C Programming Tutorial for Beginners
3:46:13
freeCodeCamp.org
Рет қаралды 14 МЛН
3218. Minimum Cost for Cutting Cake I | Weekly Leetcode 406
18:39
3045. Count Prefix and Suffix Pairs II | Weekly Leetcode 385
46:04
codingMohan
Рет қаралды 1,1 М.
Codeforces Round 667 (Div. 3) Stream + All Solutions (A-F) (+ extra)
3:55:56