Longest subarray with sum divisible by K | GfG problem of the day

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น • 46

  • @probabilitycodingisfunis1
    @probabilitycodingisfunis1  2 ปีที่แล้ว +10

    unordered_mapm;
    int ans = 0;

    m.insert({0,-1});
    int sum = 0;
    for(int i=0;i

    • @mathematics6199
      @mathematics6199 2 ปีที่แล้ว +1

      Didi, one best optmization that we can use is, maintain a vector of pairs of the prefix sum remainders and sort them. This is much useful because worst case complexity of unordered map is worser than the cost of sorting. And also hash map is much wastage of memory.

    • @joya9785
      @joya9785 2 ปีที่แล้ว

      @@mathematics6199 can you please explain it?

    • @mathematics6199
      @mathematics6199 2 ปีที่แล้ว

      @@joya9785 thats what I did na?

    • @joya9785
      @joya9785 2 ปีที่แล้ว

      @@mathematics6199 I mean if u have the sample code

    • @mathematics6199
      @mathematics6199 2 ปีที่แล้ว

      @@joya9785 haa okk

  • @krishnaradhey2814
    @krishnaradhey2814 2 ปีที่แล้ว +5

    Literally I have seen many videos but have not got such clear explanation like you did here!!

  • @dheerajkumar824
    @dheerajkumar824 2 ปีที่แล้ว +4

    it doesn't need extra 'n' complexity for sum (in brute force approach), it can be done within 'n^2' itself. Though it was further optimized.

  • @themarketverse
    @themarketverse 2 ปีที่แล้ว +7

    Nicely explained...You make these problems so easy...

  • @inthearts4525
    @inthearts4525 10 หลายเดือนก่อน

    what an explanation... just awesome.. saw a lot of videos but such a great explanation was missing... subscribing you and looking forward for many more amazing and crystal clear explanations..

  • @karma_kar9623
    @karma_kar9623 2 ปีที่แล้ว +5

    Can you solve competitive programing problems also i.e. codeforces? Your explanations are just phenomenal.

  • @gautamjangir8927
    @gautamjangir8927 2 ปีที่แล้ว +1

    The best explanation in the entire youtube ....THANKS

  • @shanayagupta4002
    @shanayagupta4002 2 ปีที่แล้ว +5

    di your explanation is very good. Thank u for delivering such quality content 😊😊😊😊

  • @lilyren7256
    @lilyren7256 2 ปีที่แล้ว +1

    awwww you are back! plz make more videos!!! And can you make a video to share how you start solving programming problems and what courses you have taken🥺🥺

    • @probabilitycodingisfunis1
      @probabilitycodingisfunis1  2 ปีที่แล้ว +1

      ❤❤❤Thank you Lily... Will try to make more videos, i just started Leetcode easy problems and moved to medium, I had taken GeeksforGeeks live DSA course

  • @zishan53
    @zishan53 2 ปีที่แล้ว +1

    It's wonderful and nice explanation ...I seen various platforms videos but u among 🔥

  • @Madhu__06
    @Madhu__06 หลายเดือนก่อน

    amazing ... easy to understand . thank you.

  • @notskinner2304
    @notskinner2304 2 ปีที่แล้ว +3

    Hard to come up with this in an interview ; I would be stuck after calculating prefix sum and would be confused how to do it using two pointers :(

  • @gizmogaurav
    @gizmogaurav 2 ปีที่แล้ว

    You make the problem so easy. Thanks 👍

  • @gigachad2419
    @gigachad2419 2 ปีที่แล้ว +2

    Do You Solve And Explain only LeetCode+GFG Or even CP Questions from CodeChef/Forces?

  • @joe0212
    @joe0212 2 ปีที่แล้ว

    Awesome. Can be slow. And, also can conclude by going through the logic once again.

  • @AnuragYadav-nj2zc
    @AnuragYadav-nj2zc 2 ปีที่แล้ว

    Great explanation !!!

  • @rrrhitk
    @rrrhitk ปีที่แล้ว +1

    literally the best explanation🔥

  • @vivekpaliwal1876
    @vivekpaliwal1876 ปีที่แล้ว

    Good explanation
    Keep it up, your channel has great future

  • @chakravarty-with-a-v
    @chakravarty-with-a-v 2 ปีที่แล้ว

    Great Explanation! Thanks a Lot!

  • @sristysingh2175
    @sristysingh2175 2 ปีที่แล้ว +1

    glad to see you back❤❤

  • @mayankshekhar4754
    @mayankshekhar4754 ปีที่แล้ว

    well explained

  • @Rajat_maurya
    @Rajat_maurya 2 ปีที่แล้ว

    Thank you

  • @samajayadeepu3476
    @samajayadeepu3476 2 ปีที่แล้ว

    well understood thanks

  • @abhisheknair5630
    @abhisheknair5630 2 ปีที่แล้ว

    Thank you very much

  • @reshmaparveen6679
    @reshmaparveen6679 ปีที่แล้ว

    🎉🎉 nic explain madam

  • @TheElevatedGuy
    @TheElevatedGuy 2 ปีที่แล้ว

    Thank you di

  • @Shadow-lx9rh
    @Shadow-lx9rh 2 ปีที่แล้ว

    Thank you again I'm able to solve this question and another question in leetcode which askd to count the number of subarray sum divisible by k (974)
    I just had to count the number of places where previously the remainder had occurred
    Thank yooooo soo much the way you explained -ve remainder concept and the whole problem was just marvelous.
    Thank you from the core of my heart. 🙏

    • @probabilitycodingisfunis1
      @probabilitycodingisfunis1  2 ปีที่แล้ว +1

      Thabn tou so much @Nightbird ..glad you found it helpful

    • @Shadow-lx9rh
      @Shadow-lx9rh 2 ปีที่แล้ว

      🙇🙏

    • @KrishnaKumar-b4m9p
      @KrishnaKumar-b4m9p 11 วันที่ผ่านมา

      @@Shadow-lx9rh u need to count the no.of times where previously remainder has occured in the map.

  • @alishabeautyparlour6283
    @alishabeautyparlour6283 2 ปีที่แล้ว

    👍🏻

  • @meandpenguinvlogs8221
    @meandpenguinvlogs8221 2 ปีที่แล้ว

    💯💯

  • @vikasviplav8678
    @vikasviplav8678 8 หลายเดือนก่อน

    got the logic but not understanding the implementation, better to implement on its own @codewithalisa

  • @chestupheadup7410
    @chestupheadup7410 8 หลายเดือนก่อน

    well explained