Longest Subarray with sum K | Brute - Better - Optimal | Generate Subarrays

  Рет қаралды 631,395

take U forward

take U forward

Күн бұрын

Пікірлер: 780
@takeUforward
@takeUforward Жыл бұрын
Let's march ahead, and create an unmatchable DSA course! ❤ Timestamps pleaseeee Use the problem links in the description.
@vishal_s583
@vishal_s583 Жыл бұрын
Thanks for your effort ❤️
@factsmadeiteasy9943
@factsmadeiteasy9943 Жыл бұрын
Bhaiya how can I keep that check marks permanently... because it always get cleaned up 😩
@leoved1073
@leoved1073 Жыл бұрын
@@factsmadeiteasy9943 bro history ya cookies clear mat karo tumhari progress cookies me save hoti hai...
@factsmadeiteasy9943
@factsmadeiteasy9943 Жыл бұрын
@@leoved1073 oh thanks bro 👍🏻
@111rhishishranjan2
@111rhishishranjan2 Жыл бұрын
i think that this problem could be done by just using hashmap.
@ashutoshbhardwaj1369
@ashutoshbhardwaj1369 4 ай бұрын
I've been watching this lecture for the last two days, and it was so frustrating that I couldn't understand the concept, even though Raj Bhaiya explained it thoroughly. After putting in about 7-8 hours, I finally understood what was holding me back. Here's what I've learned: 1. map_name.find(value)-> This function returns an iterator to the element with the key `value` if it is present in the map. If the key is not found, it returns an iterator to `map_name.end()`. 2. map_name.end()-> This function returns an iterator one past the last element of the map. If your map has a size of 4 (indexing from 0 to 3), `map_name.end()` will give you an iterator representing index 4, which is beyond the last element. 3. if(map.find(value) != map.end())-> This line was a real pain in my ass so basically this line checks whether the key `value` is present in the map. If `map.find(value)` does not equal `map.end()`, it means the key is found in the map.similarly , if `map.find(value)` equals `map.end()`, the key is not present in the map. Understanding this line was crucial for me. The `.find()` function returns an iterator to the element if it is present, or `map.end()` if it is not. So, the condition `if(map.find(value) != map.end())` essentially means, "if the key `value` is found in the map." If you've read this far, all the best, buddy! I was literally crying inside after watching the video again and again, but if a noob like me can understand it, you will definitely nail it. Haha. Thanks, Raj Bhaiya. ❤
@Srijan-ye7xw
@Srijan-ye7xw 4 ай бұрын
Proud of your efforts bud ❤ let's keep going
@archanashah4542
@archanashah4542 4 ай бұрын
Thanku this helped a lot
@randomtsareenalover9014
@randomtsareenalover9014 4 ай бұрын
thanks a lot bro, im on the hard section rn and was stuck on the longest zero sum problem and i found this!
@dikshabisen504
@dikshabisen504 3 ай бұрын
you stuck over the thing where map comes....i cant even get the approach ...ye longest subarray ka approach hi nhi ghus rha bhaiii
@nirbhaybhardwaj4330
@nirbhaybhardwaj4330 3 ай бұрын
Thanks a lot buddy!
@viveknandan4950
@viveknandan4950 Жыл бұрын
When Striver says no one will teach you in such depth, he means it
@Awanderer15
@Awanderer15 Жыл бұрын
To all those whose mind are like " shyd coding is not for me" after seeing this question Take my one advice am the one solving it from 11 :am in the morning and understood it at 7 20 pm of evening I between my mind qas like chod de "pr bhaiya chodna hi toh nhi hai tabhi toh smjega" So give yourself a shootout and say striver bhaiya i will play you once more and play it back to back even if you have watched for 100 times play it slowly took a pen copy and try to understand what bhaiya is saying 🎉🎉
@thevaishndra
@thevaishndra 8 ай бұрын
was literally feeling the same, but you sowed a new hope in me
@vartikasharma2587
@vartikasharma2587 7 ай бұрын
thanks for this comment !!!instilled hope in me.
@rishabhinc2936
@rishabhinc2936 6 ай бұрын
cringe
@v.keerthigakeerthi428
@v.keerthigakeerthi428 6 ай бұрын
🥺🥺
@DTALKS01
@DTALKS01 5 ай бұрын
i am abouve to change a someone else video but you give me hop
@Piyushraj0
@Piyushraj0 Жыл бұрын
TIMESTAMPS 0:00 Intro 0:43 Problem Explanation 3:37 Brute force approach 10:50 Better approach (Both positives + negatives) 26:57 Time complexity of Hashing based better solution and why its best for both positives and negatives 28:55 Optimal solution (positives only) 37:52 Time complexity of two pointer based optimal solution
@MeiteiProgrammer
@MeiteiProgrammer Жыл бұрын
thanks dude
@Yseja
@Yseja Жыл бұрын
Thank you bro
@salihedneer8975
@salihedneer8975 Жыл бұрын
Striver please add this so everyone wud be get useful of this
@LeelaLakshmiKundi
@LeelaLakshmiKundi Жыл бұрын
thanks bhai
@aadarshanthony8622
@aadarshanthony8622 27 күн бұрын
Thanks bro
@afzhalahmed2051
@afzhalahmed2051 Жыл бұрын
You are helping families not individuals. Thanks for this.
@utsavseth6573
@utsavseth6573 Жыл бұрын
Please keep this series continued. Brilliant work Raj. I am speechless. An if anyone reading this, and you have a difficulty understanding, don't give up, just watch 2-3 more times, you shall understand, trust me.
@Akash-yr2if
@Akash-yr2if Жыл бұрын
LOL, I came back today and now the things are getting cleared.
@shivvratraghuvanshi522
@shivvratraghuvanshi522 Жыл бұрын
​@@Akash-yr2ifyeah!!
@barnam_das
@barnam_das 9 ай бұрын
thats the spirits boys, lets goooooo !!!!!!!!
@sourabhtiwari5137
@sourabhtiwari5137 7 ай бұрын
for one question , 3 hours is it a joke
@gunslingerlynx3964
@gunslingerlynx3964 4 ай бұрын
That hashing one went above my mind maybe need to watch it again
@rwordspecialist6734
@rwordspecialist6734 2 ай бұрын
Fr may be after few days
@ronaldosingh7099
@ronaldosingh7099 14 күн бұрын
The same is the case with everyone. Don't worry.
@JustExploreByTravel
@JustExploreByTravel 4 ай бұрын
I am following your playlist for DSA. I got subarray of string related problem in my JP Morgan interview. I have explained the approach as you taught. It was quite simple for me to explain the approach as I had watched your this video.. Thank you so much sir you are doing very well.
@Wonderfully_ok
@Wonderfully_ok 2 ай бұрын
did u get into jp morgan?
@kushagrakulshrestha2966
@kushagrakulshrestha2966 21 күн бұрын
do answer the below comment
@eklavya22k34
@eklavya22k34 Жыл бұрын
Those who understand the beauty of ur optimal codes, will agree, ALL UR LEC.S ARE PURE GOLD. U are a gr8 GURU .... sharing such exceptional lec.s for free is superb SERVICE FOR MANKIND. U are empowering youth ... making difficult topics look like easy .... u explain everything so easilty ... study looks like fun when u teach. Codes can revolutionise the world ... can take us to distant planets.... Codes are like miracle ... the way incredible creation like AI is developed .... Sw Er.s are next Gen soldiers of nation. They can fuel engine of growth and contribute in development of nation and growth of humanity. U r doing exceptional work ... Thank for evth..... God bless u ... Tc.
@tahaansari5621
@tahaansari5621 Жыл бұрын
Had to watch it twice to understand it like 95% but did understand it. Really impressive stuff!
@takeUforward
@takeUforward Жыл бұрын
It's easy if you do a dry run on yourself
@DevashishJose
@DevashishJose Жыл бұрын
@@takeUforward yes I was also confused but when I did the Dry run I got it.
@crazybro4383
@crazybro4383 7 ай бұрын
Mujhe both positive and negative ka optimal samajh hi ni aaya, like approach I understood in one go and found it very easy. But code ni smjh aaya 2 baar dekhne par bhi. I also refered to striver's website but smjh hi ni aara kuch. Should I leave it for now ? (ps- I am a beginner first year student)
@ViditPandey06
@ViditPandey06 7 ай бұрын
@@crazybro4383 just keep working you will eventually understand.
@Srinivasssssss
@Srinivasssssss 10 ай бұрын
Outstanding Explaination... I cant able to understand by watching this video even 2 times. It doesnt mean, striver didn't explained well. He explained very well. so, people who are not able to understand it well, try to watch it again and again...! Dont search for other videos for this question, and if you even search, I will assure you that, you cant able to find better explaination than this..! Striver, Thank you so much...!
@AbhishekPandey-dj2eo
@AbhishekPandey-dj2eo Жыл бұрын
Thank you striver for this ultimate course, I was trying from many days and searching to starts DSA, and this course made me do it Today day 15 😅
@akworld2739
@akworld2739 Жыл бұрын
hello bhai apki growth kaisi hai abhi kya question ban rhe mai beigner hu mujse to easy bhi nhi ho rhe hai kitna time spend karna chiye ek question mai
@renewbhagwat5475
@renewbhagwat5475 4 ай бұрын
@@akworld2739 same goes for me . ab ban rahe hai kya bhai questions ?
@DK-ox7ze
@DK-ox7ze Жыл бұрын
Absolutely brilliant. Haven't seen anyone else on KZbin explaining any dsa problem with this much clarity.
@tanishqbansal8462
@tanishqbansal8462 Жыл бұрын
Understood !! Both Interviewer And Me Are Super - Duper Impressed !!
@arunavabanerjee5608
@arunavabanerjee5608 Жыл бұрын
The best video till now I have seen for this problem . 41 minutes explanation for a single problem is just a next level thing.
@tanya8353
@tanya8353 11 ай бұрын
You are doing a wonderful job man!!! Really grateful to people like you who provide such quality content with such a dedication !!
@hritikshah54
@hritikshah54 8 ай бұрын
Amazing!!💗💗 Also, we can further trim down the code provided in 26:46. If we intialize our HashMap with map.put(0,-1), we can skip checking the condition of if(sum==k)
@adityalawande1771
@adityalawande1771 Ай бұрын
After spending entire 2 days on this I have finally understood the lecture and the concepts of subarray. It was not easy at first but after spending all the time I came across a comment that saying "It wont be easy, but it will be worth it" on this I can say that It was definitely worth it!! The point is I still don't know if DSA is important or not or any other blah blah. But the efforts I am willing to give to learn it is what amazes me. If a guy like me can understand this you can too!! Don't give up!!
@vm1662
@vm1662 11 ай бұрын
Teaching is an art and you have nailed it, my friend. Another amazing one from Striver. Thank you!
@vigneshpandi3013
@vigneshpandi3013 2 ай бұрын
This man is a god straight from heaven for programmers. The Clarity he has in his explanation is absolutely Amazing! Never seen a guy who is so passionate teaching DSA. Love you Raj Bhai! ❤
@bhanupratapjaiswal4741
@bhanupratapjaiswal4741 Ай бұрын
In bruteforce approach we can also add the condition to reduce the number of operations that if(sum >K)break from the inner loop if the array contains positive elements only
@Atharva_kathiyawadi
@Atharva_kathiyawadi Жыл бұрын
kya aadmi h yaar!! dedication amazing 😍
@Akash-yr2if
@Akash-yr2if Жыл бұрын
Watching the video 2nd times, first time was yesterday and now things are getting little inside my head. Thnx Striver.
@vinaynagle720
@vinaynagle720 Жыл бұрын
This is the lecture when I understand hashing properly. Thanks striver👍
@codingaspirant9446
@codingaspirant9446 Жыл бұрын
You are like Virat Kholi.
@justcode7326
@justcode7326 Жыл бұрын
Consistent and hardworking
@vinaykrishna747
@vinaykrishna747 Жыл бұрын
Yes...
@ArnabBhadra02
@ArnabBhadra02 Жыл бұрын
Better than kohli kohli can't secure 1000 students' future but striver can.
@helloworld2054
@helloworld2054 Жыл бұрын
Don't compare a great teacher with a choker
@calisthenics5247
@calisthenics5247 Жыл бұрын
​@@ArnabBhadra02 yeah but kohli do donate money to save lives of lakhs of people and he also made our country pride a large number of times you fools
@rohansachdeva627
@rohansachdeva627 10 ай бұрын
Took me 3-4 passes to finally get the thought process through my head. But UNDERSTOOD it finally :)
@visheshdwivedi2256
@visheshdwivedi2256 6 ай бұрын
Making my DSA journey superb ❤ hats off to u
@Codinguntiligotplaced
@Codinguntiligotplaced Ай бұрын
best explanation watched it 3 times because of map part but finally crystal clear thanks raj bhaiya
@AyuKG
@AyuKG Жыл бұрын
thank you so much striver for everything ,today i did this question on my own without watching video but only with my intution it took me around 3hrs but it felt so good and its all because of you. thanks a lot (raj sir)😇❤ @take U forward !!🔥🔥🔥🔥🔥🔥🔥
@abhaysingh4-yearb.tech.mec565
@abhaysingh4-yearb.tech.mec565 8 ай бұрын
Bhai kha placement hui
@shubhamagarwal1434
@shubhamagarwal1434 2 ай бұрын
#Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India....
@RaunitJaiswal-s9v
@RaunitJaiswal-s9v Ай бұрын
The find(rem) method returns an iterator (or pointer-like object) pointing to the key rem if it exists in the map. f rem does not exist in preSumMap, find(rem) returns preSumMap.end(), which is a special iterator representing "one past the end" of the hashmap. The expression != preSumMap.end() checks if the key rem was found in the map. If rem is found, it means there exists a prefix sum rem somewhere before the current index i. thank you striver bhaiya jinko nahi samaj aata c++ stl ka playlist apne ache se nahi dekha hai isliye aise hora hai
@om3478
@om3478 Ай бұрын
Thanks i was confuse but now its clear
@tanmaykarn
@tanmaykarn Жыл бұрын
Understood in one go. but had to pause a lot and dry run everything in pen paper. nice question!
@SatyaMantha
@SatyaMantha 23 күн бұрын
Thank you Striver, I comment on every video of yours because it helps me a lot
@AnkitGokhroo-i3l
@AnkitGokhroo-i3l 4 ай бұрын
One of the best explanation for this type problem. Need to see the video 3 times but at the end got it.
@siddharthdixit5009
@siddharthdixit5009 2 ай бұрын
Really striver you are awesome lot of people who explain concepts but the way you explain the concepts its mind blowing .Really impressed with your teaching skills
@PrithaMajumder
@PrithaMajumder 4 ай бұрын
Raj, Thanks a lot for This Amazing Video about C++ Arrays Video - 4 Completed ✅
@luckydev9006
@luckydev9006 Жыл бұрын
Finally understood the concept 😮‍💨
@simran5048
@simran5048 Жыл бұрын
That much clarity and explanation 🔥🔥🔥
@code247
@code247 10 ай бұрын
wonderful you've taught both approaches together.
@KushalPandita
@KushalPandita Жыл бұрын
This lecture is too good 😍🤩 and the Mentor , he obviously needs no introduction 💥
@Lucifer-xt7un
@Lucifer-xt7un Жыл бұрын
This is called consistency❤❤
@transformers-ai
@transformers-ai 3 ай бұрын
this series is really commendable. Learning a lot.
@haryanvibhajan001
@haryanvibhajan001 26 күн бұрын
i understood it completely now, first it was seeing impossible for me to solve as i saw the solution from jut code but your explanation is literally just❤‍🔥❤‍🔥🔥🔥
@domorebemore3192
@domorebemore3192 10 ай бұрын
That satisfying song at the end .I always wait till the end for that.😂😊❤
@saouli1632
@saouli1632 9 ай бұрын
37:42 Understood ❤ dada .Thank You
@kaichang8186
@kaichang8186 23 күн бұрын
understood, the best explanation I have ever seen
@footballcreativeeverywhere260
@footballcreativeeverywhere260 Жыл бұрын
You are my inspiration bhaiya .. And I am really a big fan of you, blessing me to become like you.
@DeepanshiBhardwaj-y1t
@DeepanshiBhardwaj-y1t 7 ай бұрын
genuinely one of the best cousrse man!!
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 Жыл бұрын
This is life saving. Salute!
@cinime
@cinime Жыл бұрын
Understood! Amazing explanation as always, thank you very very much for your effort!!
@joeljacob4685
@joeljacob4685 Жыл бұрын
Absolutely Brilliant Explanation !! You explained the problem with so much clarity.
@wanderer_ankur
@wanderer_ankur Жыл бұрын
awesome explanation, i will watch it again and then solve to understand it completely.
@KarumuriYasaswini
@KarumuriYasaswini 7 ай бұрын
I still don't understand how the optimal solution is coded. - While explaining the thought process and dry run, the first step we did was to keep adding the a[p2] elements.Then if sum exceeds, remove a[p1]s. - It's strange why these steps got reversed while coding. In the code, first we remove the a[p1]s and then kept on adding. -A general thought is to follow the thought process/ dry run. Surprisingly, if we write the code following the thought process it'll fail. That was the mistake I've made. -But, still I've understood. Thanks Striver!
@rida4002
@rida4002 10 ай бұрын
i love this guy, he's like talking to you in person.
@AS-gf3ci
@AS-gf3ci Жыл бұрын
It's a bit complex to learn this in the first go. Maybe it would require re-watching the same multiple times.
@rohanmajhi1329
@rohanmajhi1329 Жыл бұрын
Yeah, I thought that was not my cup of tea but after watching it 2nd time, I got the approach!!
@akashddeepchitransh4537
@akashddeepchitransh4537 Жыл бұрын
Really power packed video 🥲
@prasannagodiyal6736
@prasannagodiyal6736 3 ай бұрын
bahut time lag gaya samajhne mai but finally samajh aa hi gaya
@prathameshborse258
@prathameshborse258 5 ай бұрын
Understood Bhaiya ❤❤ crystal clear and to be point explanation..!
@itzmartin20
@itzmartin20 Жыл бұрын
what a crystal clear explaination, understood!
@shwetachoudhary9003
@shwetachoudhary9003 3 ай бұрын
it was soo tought for me... i was loosing my self confidence... i was be like shayd ye mujhse nhi hoga but then i saw a comment of a guy who said that his condition was same and he gave his whole day to this then i started again and after 3.5 hrs i got it. So don't give up just be ready to give extra efforts
@amanshrivastav0405
@amanshrivastav0405 9 ай бұрын
In the first question, can we break the inner loop if the sum is greater than the required k because the loop only contains positive integers? int longestSubarray(vectorarr, int k){ int maxLength = 0; for(int i = 0; i < arr.size(); i++){ int sum = 0; for(int j = i; j < arr.size(); j++){ sum += arr[j]; if(sum == k){ maxLength = max(maxLength, j-i+1); }else if(sum > k){ break; } } }return maxLength; }
@priyanshusinha68
@priyanshusinha68 14 сағат бұрын
For the sliding window technique it is not working for the case.. Arr={2,3,0,0} here k=3. IT IS GIVING THE ARRAY AS {3} WHILE IT SHOULD BE {3,0,0}
@omsuryawanshi5478
@omsuryawanshi5478 2 ай бұрын
the one who comes up with this solution on his own must be a genius
@Sillysmiles76
@Sillysmiles76 Жыл бұрын
You made DSA very interesting😄
@soumiyamuthuraj3516
@soumiyamuthuraj3516 4 ай бұрын
Amazing quality, Cant thank you enough. top notch explanation, and nobody teaches DSA in this depth from my learning experience. i dont have words to thank you, may god give you all good health , happiness and wealth to continue this noble cause,
@AdityaKumar-be7hx
@AdityaKumar-be7hx Жыл бұрын
WE can simplify moving to right is we just initilize the sum to zero: int longestSubarrayWithSumK(vector nums, long long targetSum) { int n = nums.size(); // Size of the array. int left = 0, right = 0; // Two pointers. long long currentSum = 0; // Initialize currentSum to 0. int maxLength = 0; while (right < n) { currentSum += nums[right]; // Add the current element to the currentSum. // If the current sum is greater than the target sum, reduce the subarray from the left // until the current sum becomes less than the target sum. while (left targetSum) { currentSum -= nums[left]; left++; } // If the current sum is equal to the target sum, update the maxLength. if (currentSum == targetSum) { maxLength = max(maxLength, right - left + 1); } // Move the right pointer forward. right++; } return maxLength; }
@himadrimahata8668
@himadrimahata8668 Жыл бұрын
thanks a lot
@IncredibleJourneyIndianRailway
@IncredibleJourneyIndianRailway 8 ай бұрын
thank you
@tunepa4418
@tunepa4418 5 ай бұрын
Exactly, prefix sum is not necessary here. I am assuming he is just trying to explain the concept but it's really not necessary as all the numbers are positives
@saivaibhavrox
@saivaibhavrox Ай бұрын
@@tunepa4418 it becomes necessary if we have negatives. but as you said for +ves we dont require prefix sum but it's his way to teaching. He always involves the solutions right from brute to optimal.
@hero_007
@hero_007 4 күн бұрын
19-oct-24 - Understood. Great explanation. Thank you & God bless you!
@dhruvrawatt9
@dhruvrawatt9 Жыл бұрын
following and loving this course ❣❣
@raghumanda2tanush496
@raghumanda2tanush496 Жыл бұрын
brilliant 2 pointer explanation
@ANMOLAHIRWAR-kg8lv
@ANMOLAHIRWAR-kg8lv 3 ай бұрын
a wonderful question and a wonderful explaination.
@abhishekgarg5017
@abhishekgarg5017 8 ай бұрын
best In-depth explanation
@purvi9958
@purvi9958 Жыл бұрын
Thankyou sir for such an elaborate explanation!
@musicalcasio5146
@musicalcasio5146 Жыл бұрын
in which year you are...?
@SatwikSharma21bcs080
@SatwikSharma21bcs080 4 ай бұрын
✦ The video covers solving the longest subarray with a given sum problem. 00:04 ✦ Find the longest subarray with a sum of K. 02:28 ✦ Finding the longest subarray with sum K using brute force. 06:52 ✦ Optimizing brute force with hashing 09:08 ✦ Algorithm to find subarrays with sum K 13:43 ✦ Understanding subarrays and prefix sum equivalence to K 15:56 ✦ Calculate the length of the longest subarray with sum K. 20:01 ✦ Using prefix sum and hash map to find longest subarray with sum K. 22:09 ✦ The better solution is optimal for arrays with positives, zeros, and negatives. 26:19 ✦ Understanding time and space complexity for better and optimal solutions 28:29 ✦ Finding the longest subarray with a given sum 32:25 ✦ Moving right and adding the elements while staying within the boundary. 34:35 ✦ Time complexity is O(2N), space complexity is O(1) 38:45 ✦ Using hashing for an optimal solution 40:50
@juliechoudhary9582
@juliechoudhary9582 Жыл бұрын
Thank you so much for such an easily understandable course.
@abhimanyuambastha2595
@abhimanyuambastha2595 6 ай бұрын
While neetcode is good, I always come to this channel for better indepth explanation and intuition. And the dry runs are a plus
@sayakghosh5104
@sayakghosh5104 Жыл бұрын
Understood super explanation as always.
@PrinceTripathi-j7u
@PrinceTripathi-j7u 9 ай бұрын
Watching Your Lecture on the night of 31st December.
@kushagramishra5638
@kushagramishra5638 Жыл бұрын
understood ! Next level explanation sir 🙇‍♂
@knl-tu1no
@knl-tu1no Жыл бұрын
Awesome sir.Kindly solve String problems as soon as faster. It will be helpful for my placements.
@dinimeegada9167
@dinimeegada9167 Жыл бұрын
Big fan of your teaching and effort anna ❤
@blue.262
@blue.262 Жыл бұрын
Anna Are you telugu??
@vamshi2639
@vamshi2639 5 ай бұрын
That OVERALL was crazy !😂😂
@subratkumarsahoo3785
@subratkumarsahoo3785 Жыл бұрын
18:17 I can't understood the brute solution using hashing. It goes beyond my head😂..
@suyashagrawal1102
@suyashagrawal1102 7 ай бұрын
bruh try rewatchung the video
@manavmalhotra5024
@manavmalhotra5024 6 ай бұрын
true i figure out the optimial solution before brute and better approach
@CodeWithMeee
@CodeWithMeee 5 ай бұрын
same, and also hashing means use of hashMap right but where he used Hashmap ? please someone correct me if I am wrong
@nirbhaybhardwaj4330
@nirbhaybhardwaj4330 3 ай бұрын
@@CodeWithMeee bro! map is also used for hashing .
@CodeWithMeee
@CodeWithMeee 3 ай бұрын
@@nirbhaybhardwaj4330 yes, now i understand...I have no knowledge about that earlier. thanks
@yamini436
@yamini436 Жыл бұрын
Love u striver bhaiya. You are DOPE!
@keshavgarg8407
@keshavgarg8407 Күн бұрын
just a normal fact that .end() function refers to the one past last element in cpp to get better functioning across different data structures , take example of am empty array, if .end() refer to the last element , both .begin() and .end() would have referred the same element , it serves as the end of the container
@dhruvsolanki4473
@dhruvsolanki4473 Жыл бұрын
Super cool explanation.
@shaiksoofi3741
@shaiksoofi3741 9 ай бұрын
Watched twice to grasp the concept of hashing Tq
@ishangujarathi10
@ishangujarathi10 Жыл бұрын
Amazing intuition as always!!!!
@chethanprabhu4475
@chethanprabhu4475 4 ай бұрын
@Striver JUST FYI. The problem link attached in the striver A to Z sheet is of total count of sub arrays and not longest subarray
@guneeshvats46
@guneeshvats46 4 ай бұрын
Amazing explanation striver
@shatulbansal4756
@shatulbansal4756 9 ай бұрын
Heyy Striver, Can we use the variable-sized sliding window approach for this question ??
@konankikeerthi
@konankikeerthi 4 ай бұрын
Understood. Thanks for your efforts bro.
@riteshbisht94
@riteshbisht94 Жыл бұрын
Virat Kohli of Programming 🌟🗿
@vishalakulkarni2620
@vishalakulkarni2620 Жыл бұрын
Hey did u get how k=3 in 1st eg then in last eg k=6
@anmol3749
@anmol3749 3 ай бұрын
Understood Thank you Striver
@prajaktakapoor7520
@prajaktakapoor7520 Жыл бұрын
"UNDERSTOOD" Thanks bhaiya
@MayankSengar-y3g
@MayankSengar-y3g 4 ай бұрын
Understood great video for arrays problem solving
@Aryan-ji2nk
@Aryan-ji2nk Жыл бұрын
took me more than 5 attempts to understand the edge case 😵‍💫
@DevanshVerma-u1v
@DevanshVerma-u1v 26 күн бұрын
this video is exceptional.
@sunnymishra2120
@sunnymishra2120 Жыл бұрын
In case of the Optimal solution, if arr=[ 1,1,1,1,1,1,1] , k = 1 Then the left pointer will always move whenever the sum will be increased by right pointer. So I think in the worst the case Time Complexity of the optimal solution will be O(n^2) . Please correct me if I'm wrong ! @takeUforward
@aesthetich9730
@aesthetich9730 Жыл бұрын
You are right about the pointers moving in each iteration but the complexity is where you are wrong.. It would not be O(n^2) rather it would be O(2n) (n times the left pointer will move and n times the right pointer will move) and O(2n) is equivalent to tc of O(n).
@gool7947
@gool7947 Жыл бұрын
n^2 tab hota agar har 1 right move ke lie left puri array traverse kr jata but in this case 1 right ke lie 1 left move hora hai har baar. left =n,right=1 =>0(n*1) Worst Case would be - arr=[1,1,1,1,1,1,1,100], k=10 yahan pe right 7 baar move krega aur +100 hote hi sum>k ho jaega. sare left hatane par bhi sum
@krishnasharma-le1mc
@krishnasharma-le1mc Жыл бұрын
This is the Bestttttt Videooo I had found on KZbin
怎么能插队呢!#火影忍者 #佐助 #家庭
00:12
火影忍者一家
Рет қаралды 47 МЛН
VAMPIRE DESTROYED GIRL???? 😱
00:56
INO
Рет қаралды 8 МЛН
Count Subarray sum Equals K | Brute - Better -Optimal
24:09
take U forward
Рет қаралды 318 М.
Largest Subarray with Zero Sum | Amazon | MMT
13:54
take U forward
Рет қаралды 215 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 146 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 460 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 187 М.
Subarray Sum Equals K - Prefix Sums - Leetcode 560 - Python
15:19