Largest Subarray with Zero Sum | Amazon | MMT

Поделиться
HTML-код
  • Опубликовано: 5 ноя 2024

Комментарии • 198

  • @takeUforward
    @takeUforward  4 года назад +68

    Understooooooooooooooood?
    .
    Instagram(connect if you want to know how a SDE's normal life is): instagram.com/striver_79/
    .
    .
    If you appreciate the channel's work, you can join the family: bit.ly/joinFamily

    • @sagardas4569
      @sagardas4569 4 года назад +1

      A biiiiiiggggggg yesssssss😋❤️😍

    • @firefangful
      @firefangful 4 года назад

      Can you please give some articles related to time complexity in maps. I do not understand why time complexity of unordered map is nlogn ...where does this logn come from?

    • @sagardas4569
      @sagardas4569 4 года назад

      @@firefangful codeforces.com/blog/entry/50626
      I think it should help you.

    • @AkashRaj-ib6wz
      @AkashRaj-ib6wz 3 года назад

      yoooo

    • @unsaturated8482
      @unsaturated8482 3 года назад

      couldnt ask for more.

  • @renon3359
    @renon3359 3 года назад +71

    Can't even say how good this guy is. Awesome explanation brother.

    • @xdprogrammer9579
      @xdprogrammer9579 3 года назад

      Thanx

    • @ghost10326
      @ghost10326 Год назад +1

      @@xdprogrammer9579 Bro why are u saying thanx to that guy. is it your channel ?
      🐒

    • @theexplorer9012
      @theexplorer9012 9 месяцев назад

      @@ghost10326 🤣🤣🤣🤣🤣🤣🤣🤣

  • @akashr8367
    @akashr8367 Год назад +1

    That joyful moment when I understood this approach is invalueable. Thank you so much for this explanation!

  • @mritunjay4ever
    @mritunjay4ever 2 года назад +5

    what a beautiful explanation striver. Hats off man!!! Hope to work with you as an engineer.

  • @adityachandan8571
    @adityachandan8571 4 года назад +3

    I just love the way you explain every approach nobody else is even near you in terms of explaination

  • @naro.tam_
    @naro.tam_ 3 года назад +35

    I solve 60% of your sheet by my own but comes here every time to see better approach

    • @technoakshay20
      @technoakshay20 Год назад

      How much question solve ?

    • @sanainaa9972
      @sanainaa9972 5 месяцев назад

      Can you please forward that cheat sheet

    • @GeetainSaar
      @GeetainSaar 4 месяца назад

      ​@@sanainaa9972search tuf dsa sheet on Google it's free

    • @ThePROestRedn99
      @ThePROestRedn99 Месяц назад

      ​@@technoakshay20 bro don't worry it was brute force solution.....he came here to watch tha better and optimal ones😂

  • @akashjha7090
    @akashjha7090 3 года назад +3

    today my confusion about storing values in hash table gets cleared.Thank you

  • @aadityaupadhyay6264
    @aadityaupadhyay6264 4 года назад +39

    Striver: And to understand this in much better way
    Clement's girlfriend : Do you know what the scariest thing in the world is😂?

  • @aishwarya1895
    @aishwarya1895 4 года назад +8

    Literally vaeya you are God and true motivation for people who are not from an IIT
    Thanks for such a true guidance....

  • @deepakdass4710
    @deepakdass4710 Год назад

    I was stuck in this question but you helped me to solve this. Thanks brother.

  • @sujalgupta6100
    @sujalgupta6100 2 года назад

    thanks.......... great explanation by showing dry run process

  • @akanshkumar2876
    @akanshkumar2876 4 года назад +5

    Your efforts are really appreciable 🙏

  • @mansigoyal4796
    @mansigoyal4796 3 года назад +2

    your videos give us a reason to complete the sheet ...Thanku 💖💖

  • @prathamdeora3783
    @prathamdeora3783 4 года назад +5

    Thank you bhaiya for giving best material of knowledge

  • @prakharsankrityayan1842
    @prakharsankrityayan1842 2 года назад +2

    The first if condition can be removed by initialising mpp[0] = -1

  • @ranasauravsingh
    @ranasauravsingh 2 года назад +1

    UNDERSTOOD... !!!
    Thanks striver for the video... :)

  • @jatinkumar4410
    @jatinkumar4410 Год назад +1

    Amazing explanation. Cant we consider time complexity of unordered_map as constant and hence overall time complexity as O(n)?

  • @shreyasingh542
    @shreyasingh542 Год назад

    The only dry run I listen to very carefully, other ones seem boring and useless :)

  • @abhishekmore5856
    @abhishekmore5856 2 года назад +1

    if we put mpp[0]=-1 then we don't need to write if(sum==0) maxi=i+1

  • @yashsomani3042
    @yashsomani3042 2 года назад

    You really teach very well.
    Thank you so much!

  • @priyankarai7005
    @priyankarai7005 4 года назад +10

    hey striver, i have a doubt with your complexity analysis. In some of the videos you say hashmap takes logN time for operation and in some you say constant time. Can you please tell me if am right about maps that unordered map takes average time of O(1) but ordered map takes logN time.

    • @takeUforward
      @takeUforward  4 года назад +5

      Yes u r right. Unordered worst is o(n)

    • @agyaani8060
      @agyaani8060 3 года назад

      How to identify which is ordered map or unordered map??

    • @priyankarai7005
      @priyankarai7005 3 года назад +2

      @@agyaani8060 if u declare it as map only then it's ordered...for making it unordered we mention unordered_map

    • @agyaani8060
      @agyaani8060 3 года назад

      @@priyankarai7005 in java?

  • @sumansingh6886
    @sumansingh6886 2 года назад

    very nice explaination.
    TYSM striver bhaiya

  • @vamsikrishnasai1682
    @vamsikrishnasai1682 Год назад

    The code for this problem is same code we did for longest subbarrau with sum k,both are same?

  • @nammi895
    @nammi895 2 года назад

    Will never forgot this question. Was asked in grab interview couldn't think of hashmap approach

  • @mrxxiii1807
    @mrxxiii1807 2 года назад

    thans bro understood , and coded the logic in first go without seeing the code

  • @navyasri5077
    @navyasri5077 3 года назад

    I say so many vedioes but the problem was not clear at the time of leaving the problem yt god recomended this. Understooodddd

  • @amaanarshad4150
    @amaanarshad4150 2 года назад +2

    How can we print that subarray ?

  • @ritikshandilya7075
    @ritikshandilya7075 6 месяцев назад

    crisp & Clear. Thanks @striver

  • @mehershrishtinigam5449
    @mehershrishtinigam5449 Год назад

    after you read the code once you realise how easy it is... i knew we had to use kadane's algorithm, im glad atleast i realised that. thanksss!!

  • @vikasbagri1225
    @vikasbagri1225 2 года назад

    I do not understand why the TC is O(nlogn)
    To the best of my knowledge I think it should be O(n)
    Correct me if I am wrong
    Any help would be appreciated

  • @gauravsharma3444
    @gauravsharma3444 4 года назад +3

    Bro channel ki FAANG playlist ko rename kro , aur starting mein #123 numbering kr do , it will be easier to understand where to start

    • @takeUforward
      @takeUforward  4 года назад +2

      playlist pe jaao sb 1 to .. tak hi h .. also sde sheet pe numbered h

  • @giraffe4375
    @giraffe4375 2 года назад

    such a wonderful logic and explanation

  • @amitsinghrana6619
    @amitsinghrana6619 3 года назад +1

    This guy make DSA way too easy😎

  • @pritishpattnaik4674
    @pritishpattnaik4674 2 года назад

    Beautifully explained , mazza agaya

  • @rahulkhandelwal7034
    @rahulkhandelwal7034 3 года назад

    Hi bhaiya , let's say the array is (1,-1,1) , so firstly it will be including in hashmap as (1,0) , now when -1 will comes , sum will be 0 , so , maxi = I+1=2 , now again when 1 will come , so it will look into the hashmap , to find 1 , but I don't know , what will it contribute to the ans , I mean what's the use of getting rid of that 1 .

    • @kumaramit04-q6c
      @kumaramit04-q6c 3 года назад

      But the max length will not change I think..

  • @hemanthreddy911
    @hemanthreddy911 Год назад

    Superb explanation..! Awesome

  • @CodeAddict-mq2nu
    @CodeAddict-mq2nu 2 года назад

    just one doubt,time complexity should be n beacause it takes constant time to acess aw well as insertion the hashmap
    please reply

  • @SristiJainBCS
    @SristiJainBCS Год назад

    Why have you taken log n complexity for unordered map?

  • @shuvbhowmickbestin
    @shuvbhowmickbestin 2 года назад

    why is this problem given under hard section in your sheet?

  • @anubhavpabby6856
    @anubhavpabby6856 4 года назад +2

    Bhaiya can we apply sliding window approach here?

    • @ayushverma7179
      @ayushverma7179 3 года назад

      complexity would be O(n log(n) ) so yeah it's applicable

  • @aryanchauhan8897
    @aryanchauhan8897 4 года назад +1

    Thanks this is the best way anyone can explain this solution to me xD

  • @al0k_singz
    @al0k_singz 18 дней назад

    why subbbarrray seem little bit different in your tone btw love this

  • @codetochange8
    @codetochange8 2 года назад

    Thanks Striver Bhaiyya..It helped a lot

  • @naitikrathore3317
    @naitikrathore3317 2 года назад +1

    Good Explanation but That Sub-Array Accent 😂

  • @being.popular
    @being.popular 3 года назад +7

    @striver bhaiya, for C++ sol, u have used unordered map but for time complexity analysis, u used ordered_map complexity. Right?

  • @laxmanbafna4178
    @laxmanbafna4178 2 года назад

    Really good explanation. why does it not seem to be an easy problem? It seems to be of at least medium level to me

  • @Codro09
    @Codro09 7 месяцев назад +1

    Lets see who is coding now!

  • @devanshmesson2777
    @devanshmesson2777 3 года назад

    Thank you so much Raj bhaiya!
    Glad I found your channel!

  • @brightfut5225
    @brightfut5225 2 года назад

    trversing will take O(N) right in java can any plss explain me

  • @manaswitadatta
    @manaswitadatta 4 года назад +1

    how the time complexity is O(nlogn) raj. Hashmap insertion and retrieval can be done in O(1) na ?

    • @takeUforward
      @takeUforward  4 года назад +2

      Depends... unordered hashmap takes N in worst case due to collisions, we can say it as n or n log n in interview and then explain !

    • @manaswitadatta
      @manaswitadatta 4 года назад

      @@takeUforward okay. Thank you. 😊

    • @agyaani8060
      @agyaani8060 3 года назад

      Using hashmap T.C will be O(n) from O(n^2)??

  • @nidharshanaranganathan289
    @nidharshanaranganathan289 3 года назад

    WONDERFUL EXPLANATION !!!!!

  • @parica117
    @parica117 2 месяца назад

    understood striver , thank you

  • @aftabalam7103
    @aftabalam7103 3 года назад +1

    @take U forward Amortized time complexity of insertion or retrieval in HashMap is O(1) then how come time complexity is O(NlogN)

    • @takeUforward
      @takeUforward  3 года назад +1

      In c++ the average case for map is logn, for unordered map its o(1) but the worst goes to o(n) in rare occasions.

    • @aftabalam7103
      @aftabalam7103 3 года назад

      @@takeUforward okay thanks bro..got it...u r doing great work...keep it up...

  • @manishmotwani3744
    @manishmotwani3744 4 года назад +3

    Nicely explained #striver sir, keep posting such videos, waiting for further video explainations from your SDE sheet.
    Your SDE sheet is the best!!

  • @simrankak7045
    @simrankak7045 3 года назад

    crystal clear explaination

  • @anveshasharma2726
    @anveshasharma2726 2 года назад

    Awesome explaination bro

  • @tanmaybarman3862
    @tanmaybarman3862 3 года назад

    jitna bhi thanks bole kam hai bhaiya❤❤❤

  • @ganeshmajeti7930
    @ganeshmajeti7930 2 года назад

    instead of first if statement in the for loop we can directly put(0,-1) in the hash map after creating it. This works.

  • @akashbabutammali4478
    @akashbabutammali4478 2 года назад

    Time Complexity O(N) right? as we traversing the array only one time and checking whether sum is present in Hashmap takes O(1). how time complexity will become O(n Log n), can anyone confirm whether am right or wrong.

  • @Tanya-ut7zs
    @Tanya-ut7zs 3 года назад

    Great clear explanation !

  • @MVECSHANTANUKUMAR
    @MVECSHANTANUKUMAR 2 года назад

    love the accent and explanation both😉😉😉😉

  • @anuragpandey8165
    @anuragpandey8165 2 года назад +18

    If we use unordered_map in C++ then TC will be O(n) only/

    • @shuvbhowmickbestin
      @shuvbhowmickbestin 2 года назад

      that's what we use, unordered_map or HashMap (java)

    • @nasim3987
      @nasim3987 Год назад

      but striver have TC of logn

    • @anuragpandey8165
      @anuragpandey8165 Год назад

      @@nasim3987 no, its n*logn

    • @parul15137
      @parul15137 7 месяцев назад

      .find fn will hav logn only even if its unordered mP

  • @sahilrao5677
    @sahilrao5677 2 года назад

    bhau lovely explained thanks
    but bro esse logic mujhe nahi aate jab mei krta hu

  • @Anand14527
    @Anand14527 2 года назад

    crystal clear explanation

  • @protyaybanerjee5051
    @protyaybanerjee5051 Год назад

    i like how he says 'subaaarrrrrrrrraayy'

  • @bhaveshkumar6842
    @bhaveshkumar6842 3 года назад +1

    Thank you so much bro!

  • @harshal0073
    @harshal0073 11 месяцев назад

    can we solve it with sliding window??

  • @nirmalm80
    @nirmalm80 4 года назад +1

    great explanation bro, thanks a lot

  • @kamalnayan5331
    @kamalnayan5331 4 года назад +2

    Thanks a lot for this much effort bhaiya 😀

  • @av21015
    @av21015 2 года назад

    superb explanation

  • @piyushkumar-wg8cv
    @piyushkumar-wg8cv 2 года назад

    How to generate all the subarrays, you have explained in Kadane's algorithm. Bro, it is two nested loops where the outer index goes from 0 to n-1 and the inner index goes from outer index+1 to n-1, you could have said this instead of sending viewers to watch your other video.
    I have seen this with many RUclipsrs that even for one line they ask you to watch their previous videos.

  • @konankikeerthi
    @konankikeerthi 4 месяца назад

    Thank you bro. Understood.

  • @SurajGaud
    @SurajGaud 3 года назад

    Great explaination

  • @abdurrahaman388
    @abdurrahaman388 4 года назад +2

    Informative 👍

  • @udaykumargadikar7909
    @udaykumargadikar7909 3 года назад

    great Explanation...!!!

  • @deeprakholiya7583
    @deeprakholiya7583 3 года назад

    Bhai it is also useful for cp.

  • @vimaltomar9336
    @vimaltomar9336 2 года назад +1

    who marked this question as easy in GFG...it's leetcode medium level i think!

  • @SatyamKumar-bw4vi
    @SatyamKumar-bw4vi 2 года назад +1

    Hare Krishna!

  • @neyovyas3992
    @neyovyas3992 3 года назад

    Thanxx bro for such a nice explanation

  • @ritikashishodia675
    @ritikashishodia675 2 года назад

    Bhaiya esa kyo horra h m part 4 pr aa gayi to merai s brute froce hi bnti h optimized nahi kya kru 😣😖😖

  • @satyamtyagi670
    @satyamtyagi670 4 года назад

    Make a python beginners series

  • @hansrajsingh0949
    @hansrajsingh0949 Год назад

    awesome explanation

  • @dhanashreegodase4445
    @dhanashreegodase4445 3 года назад

    can't we do this using Dp

  • @shanmukhavarma3361
    @shanmukhavarma3361 4 года назад

    Same problem how to solve this using segment tree pls if possible send some link, relevant problem which can be solved with segment tree

  • @divyapawar6269
    @divyapawar6269 10 месяцев назад

    hash map has average o(1) time complexity and worst case O(n).Why are you using O(logn)

  • @mirdulswarup9065
    @mirdulswarup9065 2 года назад

    content bdia hai, effort ke liye salute. But bhai english mt try kro na ek toh fake accent upar se solution itna nhi samajh aata phir english mei try krte ho mix up ho jata hai sab

  • @hiteshpanchal5772
    @hiteshpanchal5772 Год назад +1

    Thanks Striver bhai .............
    brute force ...
    int maxLen=0;
    for(int i = 0 ; i

  • @mamruthreddy6508
    @mamruthreddy6508 3 года назад

    Superrr Explanation!!!!

  • @shauryavardhansingh7917
    @shauryavardhansingh7917 3 года назад

    what if i have to return the array with those elements

    • @kumaramit04-q6c
      @kumaramit04-q6c 3 года назад

      Store the 1st and last index of the longest subarray into variables..and print i=1st to last

  • @bit-learn
    @bit-learn 5 месяцев назад

    this guy sounds like the tech guy involved in scams lol

  • @_hulk748
    @_hulk748 Год назад

    Thankyou sir Understood🙏🙇‍♂❤

  • @kunnu223
    @kunnu223 Год назад

    And this marked as easy

  • @atharvakulkarni3007
    @atharvakulkarni3007 3 года назад

    Crystal Clear ASF

  • @rishabhsharma5037
    @rishabhsharma5037 Год назад

    What's the name of this algorithm?

  • @mriduljain2522
    @mriduljain2522 3 года назад

    Simply excellent

  • @ananyatomar4249
    @ananyatomar4249 2 года назад +1

    Can someone pls share the brute force solution!!!

  • @kms8320
    @kms8320 2 года назад

    I got the similar kind of question in the interview of sprinklr, in round1, but they asked me to find sum == k

  • @gautamsaxena4647
    @gautamsaxena4647 Месяц назад

    understood bhaiya

  • @fazilkhan4032
    @fazilkhan4032 4 года назад +1

    Awesome bro!!

  • @parshchoradia9909
    @parshchoradia9909 Год назад

    Understood Sir!