I don't care how many subscribers or views you have. But you always have the best way of explaining questions. this is absolute luxury to have all this for free.
You are the only one jo ye pahle batate ho ki socha kaise jata h. Fir prove krte ho. Yhi reason hai ki apki videos baki youtube videos se better hoti h. Or aapke concept dekhne k baad mere ko code dekhne ki need aaj tk nhi hui.
Two amazing concepts : 1,2,3.....n.......m 1) Sumtill(n) % k == Sumtill(m) % k means Sum(n...m) is divisible by k. Got it Thanks to sir. 2) mod = num % k ; if (mod < 0) mod = k - mod // the edge case
Probably the best channel for learning the concept rather than the code Bhaiya confidence hai ki agar aapke saath daily LeetCode problems karte raha to kuch hi dino me pura pura khud se solve kar paunga Thanks for being there on youtube sharing all your knowledge
for anyone wondering about the school division concept : In modular arithmetic, the remainder is always a non-negative number less than the divisor. So (-4 % 7 would be = 3). you are thinking right. but In C++ (idk about other languages), the modulus operation with a negative dividend retains the sign of the dividend. Therefore, when you compute -4 % 7, the result will be -4
kya GOD ho yar ap maja hi ajjata hai..i pick question from striver sheet and if smj ni atta to try finding ur soln ki kya apne same questn pe soln banaya hai if yes toh phle mai apka dkhta thnkeww mikkuu bhiayaaa love uu
Bro , your neat code, your clear voice explaination, and your pure intention to make us learn is just unmatchable! There are very few people at you tube jo itna shiddat se pdate he. Hatts off bro! Thank youuu🫂
Bro I am addicted to your channel Day by day.what a explanation brute force code explain then code submit then Explain TLE and again optimise approach.no one is teaching from that much depth
You are awesome bhaiya I already solve the question using the map but your explanation comes like cherry 🍒 on top and by that my understanding towards the question increases to 10 times and for that really thankyou bhaiya really thankyou
wonderful explanation as always . Your method of first proving why the concept/technique works and then implementing it is awesome!! keep up the good work :)
Hey Brother , I watch your videos daily and I just want to tell you that You are doing great work . Keep it up 🤗 . Love From Gujarat ❣. Thank you for the daily videos. 🙌
Make daily videos bhaiya , it will help me to crack companies , my interview is scheduled and if I watch your video daily , i will definetly crack good companies , bcoz same I will going to explain in Interview starts from brute force to optimised. please keep uploading video daily !
A slightly better approach o(n2) whithout using prefix array the idea is to calculate the sum while building the subarrays class Solution { public: int subarraysDivByK(vector& nums, int k) { int n = nums.size(); int ans = 0; for(int i = 0;i
Nice explanation sirji.....its a request plzz try to make videos little short....you would see a lot increase in no. of views on your channel.....btw thanks
mein pehele try kiya aur n^2 solution hi likh paya then saw ur video , awesome explanation sir!! My Approach int subarraysDivByK(vector& nums, int k) { //O(n^2) int ans = 0; for (int i=0 ; i
Hi Sir, Brute force will be of O(n^2) not O(n^3) as you said at 04:49 Code: class Solution { public int subarraysDivByK(int[] nums, int k) { int sum, count=0; for(int i=0; i
this was my O(n^2) approach without prefix sum. Keep uploading. Nowadays if I get stuck I wait for your video to drop. class Solution { public: int subarraysDivByK(vector &nums, int k) { int n = nums.size(); int ans = 0; int sum = 0; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { sum += nums[j]; if (sum % k == 0) ans++; } sum = 0; } return ans; } };
Hey MIK Longest subarray with sum divisible by K can u please make a video on this topic in your free time .. it should be based on similar logic right ?
maine brute force try kia, usme kewal 70 testcase pass hua and then tle aya. Can you make a video about what are importance of constraints.. and how to decide that as per constraint which which O() or bigOmega will be accepted... becoz i thought that 10^8 cycle per second is allowed , and in question we had Constraint that n is within 3x10^4... so i thought 10^4 ka square means 10^8 tak toh chalna chahiye tha means O(n square) chalna chahiya tha but nahi chala ... plzzz ispe video banao na..explaining these complexities(sorry for typos)
Equivalent Java solution: class Solution { public int subarraysDivByK(int[] nums, int k) {
int n = nums.length; int sum = 0, ans = 0; Map modMap = new HashMap(); modMap.put(0, 1); for(int i = 0; i < n; i++){ sum += nums[i]; int rem = sum % k; if(rem < 0){ rem += k; }
Best video on youtube to understand the concept of this question..Thank you so much brother 💖
Thank you so much Varun ❤️❤️❤️
Bruv don't stop uploading you are gonna get that 1M in no time, the way you explained all the mathematical stuff was too good👍
Thanks a lot 😇❤️
++
I don't care how many subscribers or views you have. But you always have the best way of explaining questions. this is absolute luxury to have all this for free.
You are the only one jo ye pahle batate ho ki socha kaise jata h.
Fir prove krte ho. Yhi reason hai ki apki videos baki youtube videos se better hoti h.
Or aapke concept dekhne k baad mere ko code dekhne ki need aaj tk nhi hui.
True, I rarely felt the need to see the code, once I saw his explanation
True
kya video hai bhiya OP 🙂lot a way better than all bhiya's & didi's
here we are using the modulo property which is (a-b)%m = (a%m - b%m + m)%m
Thanks
Aapke 1 million jald hoga 🤩
Tysm ❤️❤️❤️
Sach me yaar. This guy is on fire
Bhaya aisa content pure RUclips m khi ni h, na hi aisi awaj ❤️
I am a huge fan of your teaching style. I have leaned DP also from your videos. You are doing a great job. Keep it up 👍.
Two amazing concepts :
1,2,3.....n.......m
1) Sumtill(n) % k == Sumtill(m) % k
means Sum(n...m) is divisible by k. Got it Thanks to sir.
2) mod = num % k ;
if (mod < 0) mod = k - mod // the edge case
Probably the best channel for learning the concept rather than the code
Bhaiya confidence hai ki agar aapke saath daily LeetCode problems karte raha to kuch hi dino me pura pura khud se solve kar paunga
Thanks for being there on youtube sharing all your knowledge
I am so glad to hear that.
And indeed we all will grow together 💪
No one explains like you bro
You are the best
Bruteforce approach - O(n3) passed 70/73 testcases
Bruteforce approach with O(1) sum testcase passed 69/73 testcases
Thanks Bhaiya , your approach always improves my logic building skills
for anyone wondering about the school division concept : In modular arithmetic, the remainder is always a non-negative number less than the divisor. So (-4 % 7 would be = 3). you are thinking right.
but In C++ (idk about other languages), the modulus operation with a negative dividend retains the sign of the dividend. Therefore, when you compute -4 % 7, the result will be -4
best way of explaining I have ever seen . Thank you so much sir .🙏
So nice of you. Thank you so much for watching 😇🙏
After trying so hard to grasp the concept, I finally came across this video and now I am thankful
kya GOD ho yar ap maja hi ajjata hai..i pick question from striver sheet and if smj ni atta to try finding ur soln ki kya apne same questn pe soln banaya hai if yes toh phle mai apka dkhta
thnkeww mikkuu bhiayaaa love uu
🙏🙏🙏❤️❤️❤️
Bhai maja aa gya ❤ itna acche sai toh kisi ne nai samjya abhi tak
The best explanation on RUclips for this video
Literally i have no words for this video....your explanation is awesome.... thankyou so much 💖
Bro , your neat code, your clear voice explaination, and your pure intention to make us learn is just unmatchable!
There are very few people at you tube jo itna shiddat se pdate he.
Hatts off bro!
Thank youuu🫂
Means a lot. Thank you so much 🙏🙏❤️❤️
Took around 1.5 hours to understand but finally it got inside my head, Thanks mate. Ye sum agar placement ka puch jarur batunga.
Thank you 😊 ❤️
Bro I am addicted to your channel Day by day.what a explanation brute force code explain then code submit then Explain TLE and again optimise approach.no one is teaching from that much depth
Bro u can make more views if u show java code as well like just see striver video.its suggestion
Sure Pankaj.
I will try that too soon.
Thanks a lot for your kind words
Sure Pankaj.
I will try that too soon.
Thanks a lot for your kind words
i appreciate the depth of explanation that you have given in this video🔥🔥
I tried this approach in my first attempt
void solve(vector& nums, int index, vector& temp) {
if(index == nums.size()) return;
vector ans;
for(int i=index; i
You are awesome bhaiya I already solve the question using the map but your explanation comes like cherry 🍒 on top and by that my understanding towards the question increases to 10 times and for that really thankyou bhaiya really thankyou
wonderful explanation as always . Your method of first proving why the concept/technique works and then implementing it is awesome!! keep up the good work :)
Tysm ❤️❤️❤️
Hey Brother , I watch your videos daily and I just want to tell you that You are doing great work . Keep it up 🤗 .
Love From Gujarat ❣.
Thank you for the daily videos. 🙌
Thanks a lot Jaydip ❤️❤️❤️
Bro your explanation is so good that I can’t even imagine how you could have been able do this
🙏🙏❤️❤️
And the PERFECTION is here
Awesome explanation, and you were right, only you explained the root reason behind everything in the approach, huge love from south india
So nice of you
Thank you 🙏😇❤️
Thank you so much bhaiya..best explanation for modulo concept 💥❤️
Kya mast samjhate ho bhai. love you bhai
Better than any video present on this problem on youtube
Make daily videos bhaiya , it will help me to crack companies , my interview is scheduled and if I watch your video daily , i will definetly crack good companies , bcoz same I will going to explain in Interview starts from brute force to optimised. please keep uploading video daily !
Sure
All the very best
the way you explain how to tackle with negative remainder is just awesome bro respect++
what awesome yaar, how did he considered 7n-4 that is still not clear. Could you please explain from where this n is coming.
Absolutely wow explanation
Best explanation on youtube.. please keep uploading solution with awesome explanation like this:)
Thank you so much 😇❤️🙏
A lot of effort was put into this video. Thank you for the explanation!
corner case is just lit🔥
29:54 great job bro this is what we want
big respect for you brother, good explanation, quality video ! please continue your DSA series as well.
A slightly better approach o(n2) whithout using prefix array
the idea is to calculate the sum while building the subarrays
class Solution {
public:
int subarraysDivByK(vector& nums, int k) {
int n = nums.size();
int ans = 0;
for(int i = 0;i
Yes, I also did the same
Splendid Explanation Bhaiya !! Thanks & keep uploading such videos !! All the best to you😊😊😊😊🔥🔥
Very nice and detailed approach✨
Very helpful!
Thank you👍
very good explanation thank you bhaiya
Amazing explanation of concepts step by step! Literally the best on RUclips!! 1M zyada door nahi
Means a lot. Thank you so much 😇🙏
Thank you so much Bhaiya ji 🙏🙏🙏
every time I am stuck in the ques, I know MIK is there for me❤🙌
Tysm Atifhu 💓
Thanks a ton for the Cumulative sum approach.
Happy to help ❤️
means remainder is
(sum%k+k)%k
for both positive and negative
Amazing explanation.
ur level of explanation 💥, tnku soo much bhai ❤
Thank you so much ❤️😇🙏
Thanks a lot
3 approaches 🔥🔥🔥
wonderful explanation
Thank you 😇🙏
This line 29:53 shows your Patience level bro.
Thanks a lot ❤️
true
You explain so well!!! Thanks a lot.
best teacher ,
Nice explanation sirji.....its a request plzz try to make videos little short....you would see a lot increase in no. of views on your channel.....btw thanks
mein pehele try kiya aur n^2 solution hi likh paya then saw ur video , awesome explanation sir!!
My Approach
int subarraysDivByK(vector& nums, int k) {
//O(n^2)
int ans = 0;
for (int i=0 ; i
Thanks a lot Pritish.
And I am so glad you tried O(n^2) on your own first. Way to go 💪💪💪
best explanation 🙌🙌
Hi Sir,
Brute force will be of O(n^2) not O(n^3) as you said at 04:49
Code:
class Solution {
public int subarraysDivByK(int[] nums, int k) {
int sum, count=0;
for(int i=0; i
thank you so much for this!!
Insane my brother⚔️⚔️🥵
thank you! big fan of your explanation
Great Work
well explained
best video bro dayum
always waiting for you video .best teacher in yt..😀😀😀
Thanks a lot Saurabh ❤️❤️❤️
Next level explanation
Bhai superb explaination!!!
Good Explained 😊
great explanation!!! keep making these videos 👍👍
Tysm Jay ❤️❤️❤️
this was my O(n^2) approach without prefix sum. Keep uploading. Nowadays if I get stuck I wait for your video to drop.
class Solution {
public:
int subarraysDivByK(vector &nums, int k) {
int n = nums.size();
int ans = 0;
int sum = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
sum += nums[j];
if (sum % k == 0) ans++;
}
sum = 0;
}
return ans;
}
};
Awesome
The O(n) approach is too hard to come up with.😅😅
@@codestorywithMIK bro why you used map in the github code instead of unordered_map?
That’s an old code. I will update it.
Thanks for reminding Shrijal
Let me update it now
@@codestorywithMIK 🙌🙌
Thankyou sir understood 🙇♂🙏❤
So glad to hear ❤️❤️❤️
Please Provide a Video on KMP and Z-Algorithm . We will be thankful
KMP - ruclips.net/video/qases-9gOpk/видео.htmlsi=WDpG81RfsXWdXUX1
Insane explanation just subscribed the channel
Thank you so much 😇🙏❤️
mza aa gya bhai..thanks
Great Explanation sir!
It means a lot. Thank you 😇❤️
Great explanation!
wonderful!!!
bhaiya make videos on lc 401 and biweekly 132 (3rd and 4th one) dp
thank you boss
iska mtlb jahan bhi subarray ki bat ho aur k diya ho divisible jaisa kch modulo baba ki jai ho soch skte .Crrct me if i am wrong.
thanks
Due to this negative remainder edge case i am unable to pass all testcases .
3 ways 🔥🔥🔥
Hidden Gem .
cumaliive sum and prefix sum are same right ?
btw there is a simpler brute force too..
for(int i=0;i
yes both are same
Best.
mind blowing brdr👌✅
🔥
Good job man.
Hey MIK
Longest subarray with sum divisible by K
can u please make a video on this topic in your free time ..
it should be based on similar logic right ?
maine brute force try kia, usme kewal 70 testcase pass hua and then tle aya. Can you make a video about what are importance of constraints.. and how to decide that as per constraint which which O() or bigOmega will be accepted... becoz i thought that 10^8 cycle per second is allowed , and in question we had Constraint that n is within 3x10^4... so i thought 10^4 ka square means 10^8 tak toh chalna chahiye tha means O(n square) chalna chahiya tha but nahi chala ... plzzz ispe video banao na..explaining these complexities(sorry for typos)
Equivalent Java solution:
class Solution {
public int subarraysDivByK(int[] nums, int k) {
int n = nums.length;
int sum = 0, ans = 0;
Map modMap = new HashMap();
modMap.put(0, 1);
for(int i = 0; i < n; i++){
sum += nums[i];
int rem = sum % k;
if(rem < 0){
rem += k;
}
if(modMap.containsKey(rem)){
ans += modMap.get(rem);
modMap.put(rem, modMap.get(rem)+1);
}
else{
modMap.put(rem, 1);
}
}
return ans;
}
}
Tysm ❤️
@@codestorywithMIK Thank YOU!
Thanks for java
moj karadi sir.
goat explanation
your channel is going to grow , best of luck , well explained
Thanks a lot Anmol ❤️
Bhaya ek vedio on all important algorithm for competitive 🙏🙏🙏 waiting for your vedio or a short ...
Sure. Soon Sourav
Op Explanation sir
Thanks a lot!
Thank you for watching 😇🙏
Thank you so much bhaiya ❤❤