Subarray Sum Equals K | Count Subarrays with Sum Equals K | Hashmap Interview Questions Playlist

Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we discuss the problem count of subarray sum equals K using hashmaps in java. In this problem,
1. You are given an array of integers(arr) and a number K.
2. You have to find the count of subarrays whose sum equals k.
To attempt and to submit this question, click here: www.pepcoding.com/resources/d...
For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
#hashmaps #datastructure #algorithms
Have a look at our result: www.pepcoding.com/placements
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education

Пікірлер: 173

  • @sleepypanda7172
    @sleepypanda71722 жыл бұрын

    I understood within the first 1:11 minutes because your way of explaining was crystal clear. Thanks a lot!

  • @vadirajjahagirdar9342
    @vadirajjahagirdar93423 жыл бұрын

    Best teacher for coding on KZread. Hands down, nobody is even close to him. Thanks Sir. I wish to meet you one day and thank you for your videos.

  • @cavi8779
    @cavi87792 жыл бұрын

    poori u tube mein sabse acha coding explanation aap hi kre ho.....jb b kisi qsn mein fnstaa hoon or us qsn ki aap ki vdo mil jaati hai to man bahoot hi khush hoo jata hai😊😊

  • @sachinkarve5272
    @sachinkarve52722 жыл бұрын

    Excellent. As someone said, the solution was clear within the first minute. Awesome!

  • @thegreekgoat98
    @thegreekgoat98 Жыл бұрын

    One of the brilliant explanation to this problem on entire KZread

  • @vetiarvind
    @vetiarvind2 жыл бұрын

    Amazing, i am not a hindi native speaker but i understood your explanation perfectly. Nice idea of doing a run through the array and explaining k and y-k and maintaining count of prefix sum occurance.

  • @vishalbarvaliya2849
    @vishalbarvaliya28492 жыл бұрын

    Sir.....apni jaaan & puri shiddat se padhata hai..ki...bas yahi efforts se kisika bhi interest and intuitions badh jayenge. Hats OFF

  • @SanaAnsari9618
    @SanaAnsari96185 ай бұрын

    After watching your video I got this problem, I tied up with this problem since long . finally you made me rid of it.

  • @piyushgaur6188
    @piyushgaur61883 жыл бұрын

    Sir ji DilJeet aapki explanation.....PEPCODING ROCKS👌❤

  • @aakashyadav6228
    @aakashyadav62283 жыл бұрын

    Congratulations on 50K. Many more achievements to come !!

  • @vandanabanny7550
    @vandanabanny75502 жыл бұрын

    I was searching for this video, you nailed it. Thanks a ton :)

  • @dhruvasoni6454
    @dhruvasoni64542 жыл бұрын

    best explaination sir, abhi ek hi video dekh rha thaa and he told me , rat ko imeediate apki dekhi and crsytal clear ++, app c++ mein bhi code kare, it would helpfull for many students

  • @sujan_kumar_mitra
    @sujan_kumar_mitra2 жыл бұрын

    Your dry run skills are really good!

  • @hehebohey3747
    @hehebohey37472 ай бұрын

    I was soo confused for this problem But sir you Have Explained Excellent

  • @Joyddep
    @Joyddep3 жыл бұрын

    Thanks for the explanation. Great visualization!

  • @ArjunSingh-of6vm
    @ArjunSingh-of6vm3 жыл бұрын

    literally nice way to explain

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta, I am glad you liked it. I also hope that you are watching till end. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

  • @sachinsharma905
    @sachinsharma9053 жыл бұрын

    Great Explanation. Thank you for your help

  • @nikhilagrawal9217
    @nikhilagrawal92177 ай бұрын

    Thanks a lot for this video. Seeing this for my interview preparation.

  • @sameersondur9030
    @sameersondur90303 жыл бұрын

    Absolutely Fantastic!! I am amazed by your ease to explain. Appreciate your help. I will send your links to my friends who are prepping.

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Awesome, thank you so much

  • @SarabjotSingh294
    @SarabjotSingh2943 жыл бұрын

    This is a really great explanation! Great work.

  • @keshav9541
    @keshav95412 ай бұрын

    sir i try to clear this question from many youtuber but the way you clearly show dry run hands down sir

  • @gayatrih2241
    @gayatrih22414 ай бұрын

    Your explanation has always been helpful!

  • @ravimishra8632
    @ravimishra86322 жыл бұрын

    Had trouble getting this ques, 4th video for on this question. Finally got it. Thanks a lot. You teaching style is great!

  • @X_y_zaid

    @X_y_zaid

    3 ай бұрын

    3rd for me😂

  • @pankajkohli9263
    @pankajkohli92633 жыл бұрын

    Very Nice explanation. Thanks for covering the edge case scenario when index from 0 to "i" itself is sum. I have solved this problem before but never thought of this case. Thanks again Sumeet Sir, Thanks Pepcoding :)

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊

  • @UEI_HimadriShekharChakraborty
    @UEI_HimadriShekharChakraborty2 жыл бұрын

    Moment at 1:00 , made all my confusions disappear , was stuck for a while till now. Thanks sir

  • @uniqueanshu4268
    @uniqueanshu4268 Жыл бұрын

    OMG.. What a explanation !🎉

  • @kartiksoni5302
    @kartiksoni53022 ай бұрын

    BEST EVER EXPLANATION.

  • @mansigoyal4796
    @mansigoyal47963 жыл бұрын

    Best channel ever. Sir you teach questions in very friendly way. Thanku sir 😊

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc

  • @harshagirish4579
    @harshagirish45793 жыл бұрын

    Excellent video. Great explanation

  • @sahiljain2524
    @sahiljain25243 жыл бұрын

    Nice explanation pata hi nhi chala kab khatam ho gya 😅.. Thank you 🙌

  • @DeepakSaini7900
    @DeepakSaini79003 жыл бұрын

    Gazab explain sir maza aa gya

  • @aashritamutkiri5071
    @aashritamutkiri5071 Жыл бұрын

    Very well explained!!!! Thank you sir!!!!!!

  • @Vishalkumar-nl2ud
    @Vishalkumar-nl2ud2 жыл бұрын

    Thank you for explanation, it really helps me.

  • @muskansawa2802
    @muskansawa28023 жыл бұрын

    tysm , itna acha hota hai jab koi hindi mai batat hai , kyuki i also think in hindi , dusre tutorial samjne mai jyada time lagta hai , thanks thanks thanks!

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @md.rejwanahmed293
    @md.rejwanahmed29317 күн бұрын

    Thanks a lot man. Finalyy i have understood

  • @saicharank9143
    @saicharank9143 Жыл бұрын

    Awesome explanation

  • @mercerkace2023
    @mercerkace20232 жыл бұрын

    Thanks for this easy explanation.

  • @iuashrafi
    @iuashrafi Жыл бұрын

    Great sir ! thankyou so much !

  • @sunilpanchal1498
    @sunilpanchal14982 жыл бұрын

    Great explanation sir, Keep it up

  • @artyCrafty4564
    @artyCrafty45648 ай бұрын

    Underrated channel

  • @rudreshajgaonkar
    @rudreshajgaonkar2 жыл бұрын

    Gajab explanation. Ek number bhai.

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Hope you love the explanation. For better experience and well organised content visit - nados.io and keep supporting us. 🙂

  • @tejasgulati3080
    @tejasgulati30803 жыл бұрын

    Thank you soo much. You are a savant at explaining these. This is the most straightforward video on the topic. Keep up the good work my man!

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊

  • @rahulranjan7567

    @rahulranjan7567

    3 жыл бұрын

    Savant, yes thats the word I would use to describe his explaining skills. He can single handedly jack up the toughness levels of interviews and this will happen in coming days. After his videos it becomes easy to visualize stuffs. Bass DP nahi phoot rahi merese lol

  • @ridgeadam8442

    @ridgeadam8442

    2 жыл бұрын

    I know Im randomly asking but does any of you know of a trick to get back into an Instagram account? I stupidly lost my login password. I would appreciate any assistance you can offer me

  • @isaacbobby8571

    @isaacbobby8571

    2 жыл бұрын

    @Ridge Adam Instablaster ;)

  • @ridgeadam8442

    @ridgeadam8442

    2 жыл бұрын

    @Isaac Bobby i really appreciate your reply. I got to the site through google and I'm trying it out now. Looks like it's gonna take quite some time so I will get back to you later when my account password hopefully is recovered.

  • @leslieamaron8053
    @leslieamaron80533 жыл бұрын

    Bro, thanks for explaining everything with so much patience. Finally samajh me aaya ki subarrays += map[prefSum - k] kyu kar rhe hai. Possible variations of question: > Find if subarray with sum exists; find range > Find biggest/smallest subarray with sum; range > Find no. of subarrays with sum; find ranges

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @sriramvemaraju845

    @sriramvemaraju845

    2 жыл бұрын

    Please try to explain in english. I understand hindi no worries for me. I could not find this explanation anywhere on KZread. You have a unique skill and deserve to have an international audience.

  • @GhostRider....
    @GhostRider.... Жыл бұрын

    Very clear explanation sir 🔥🔥

  • @atmanirbharladka4467
    @atmanirbharladka44672 жыл бұрын

    I watched 3-4 videos for this question. Here, I understood the concept in the first 1 min.

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Glad it helped! Keep learning. And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @heenasharma5076
    @heenasharma50763 жыл бұрын

    Ur explanation is always very fluid in all your videos...must watch

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta, I am glad you liked it. I also hope that you are watching till end. Will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms)

  • @tanvitripathi5743
    @tanvitripathi57432 жыл бұрын

    Very kind person

  • @ShabnamKhan-cj4zc
    @ShabnamKhan-cj4zc3 жыл бұрын

    Awsome explanation. Thanks a lot for explaining in simple terms. Keep doing the great work.

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms ) Keep learning and keep loving Pepcoding😊

  • @sahilkaul6199
    @sahilkaul6199 Жыл бұрын

    Thanks for teaching bhai

  • @pranays6503
    @pranays6503 Жыл бұрын

    Best explanation sir :)

  • @akhileshparmar1061
    @akhileshparmar10613 жыл бұрын

    You nicely explained this solution especially why 0 frequency should be added at the beginning. Thanks for making this video.

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @hiteshbhatia5609
    @hiteshbhatia5609 Жыл бұрын

    but how to print all those subarrays because if frequency of any sum is greater then 1 then how would we get more then 1 subarrays starting index from hashmap so that we can print all subarrays?

  • @sparshgupta9900
    @sparshgupta99003 жыл бұрын

    Literally feel aati hai sir aapse padke. The reason is aap proper teacher lagte ho..jaisa hame 12 and iit tak mile hai and unse padkar feel aata hai padai kaa

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @tishaagarwal9435
    @tishaagarwal94352 жыл бұрын

    thank u for the explanation

  • @niteenautade
    @niteenautade2 жыл бұрын

    Very well explained!

  • @tarunsingh5615
    @tarunsingh5615 Жыл бұрын

    lovely explaination

  • @atulsingh1438
    @atulsingh14382 жыл бұрын

    Awesome explanation 🔥

  • @abhishekkumargupta3605
    @abhishekkumargupta36052 жыл бұрын

    finally got it, thanks a lot😊

  • @kanhaiyatulsyan7560
    @kanhaiyatulsyan75603 жыл бұрын

    can we not put (0,1) in starting and check if sum==k at any instant then we do count++;

  • @shreyasvishwakarma8979
    @shreyasvishwakarma89793 жыл бұрын

    Thank you sir! Great Explanation so far!

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Glad it was helpful! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @sinister_rules
    @sinister_rules Жыл бұрын

    next level teacher👌👌

  • @ZentrexGaming
    @ZentrexGaming2 жыл бұрын

    sir maza aagaya firse

  • @GauravThinks
    @GauravThinks5 ай бұрын

    sumeet sir's explanation is 💎

  • @arupdas2210
    @arupdas22102 жыл бұрын

    I have just one doubt. If k=0 then "ans" should be "ans-1" and if ans-1

  • @mohitv7405
    @mohitv74052 жыл бұрын

    How can we display the subarray?

  • @balwantyadav724
    @balwantyadav7243 жыл бұрын

    sir ekdam mast padhaate ho aap har topic ko.. fan ho gya aapka sir

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @samarthsingh663
    @samarthsingh6632 жыл бұрын

    Sir first of all thing thank you for the explanation but i wanted to know why 2 pointer approach is failing here.

  • @rahulpothula1902
    @rahulpothula19022 жыл бұрын

    will it run for the test case [1], target = 0??

  • @leetcode7091
    @leetcode7091 Жыл бұрын

    First 1 min made me understand the solution.

  • @akhileshkumarsingh3322
    @akhileshkumarsingh3322 Жыл бұрын

    gajab!!

  • @cenacr007
    @cenacr0072 жыл бұрын

    Everytime I face a coding problem and come to utube to look for a solution, my only hope is I find a solution video by Sumeet Sir.

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Happy to help! Keep learning. And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @muskansawa2802
    @muskansawa28023 жыл бұрын

    subha se jis problem mai fail hori thi , ek baar yeh vedio dekh ke hogaya , maine ferquency nai count kiya tha yeh mera mistake tha! itni khushi XD i wish i could give this vedio a heart ❤❤

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊

  • @adarshupadhyay8738
    @adarshupadhyay87382 жыл бұрын

    sum 15 has a frequency 2 but bhaiya in the second occurence of sum 15 you have written 1 below it. it should be 2 not 1.

  • @gautamkhatik251
    @gautamkhatik2512 жыл бұрын

    wish I could have been watch this video before, was able to save a big amount of time

  • @eshanikabhattacharjee383
    @eshanikabhattacharjee3833 жыл бұрын

    how to get the intuition for such tricks

  • @madanmohanpachouly6135
    @madanmohanpachouly61352 жыл бұрын

    bahut sahee.

  • @subhamoyburman3093
    @subhamoyburman30933 жыл бұрын

    Bhaiya itne accha kaise samjha lete ho aap

  • @karthiklv29
    @karthiklv292 жыл бұрын

    Even though i dont understand hindi very well, i come here for the amazing explanations :)

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Thanks a lot 😊

  • @aryashjain7893
    @aryashjain7893 Жыл бұрын

    what if we take target-sum instead

  • @Satyam_-bb5ly
    @Satyam_-bb5ly2 жыл бұрын

    Could you please make a video on maximum subarray sum closest to k ?

  • @indranilchakraborty5949
    @indranilchakraborty59493 жыл бұрын

    Binary String With Substrings Representing Numbers From 1 To N....Sir ji iska solution missing hai.....It is in the portal but without solution vedio. Though I have done it by Brute force but can't implement map concept.

  • @DSA_Coding
    @DSA_Coding2 жыл бұрын

    gjb sir

  • @WizardsOfCode7
    @WizardsOfCode73 жыл бұрын

    but this is not working for array {1,2,3,4} and target value :6 output should be 2 ->{1,2,3} and {2,4} , but it is showing 1

  • @coolgamerplayer2964

    @coolgamerplayer2964

    Жыл бұрын

    it is talking about subarray not subesquence

  • @alokkulkarni10
    @alokkulkarni103 жыл бұрын

    Explanation mast hai.. English subtitles add kar do, International viewers bhi add ho jayenge

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou! Hnji, krvata hu add beta technical team ko bol k

  • @shivammehta9661
    @shivammehta96613 жыл бұрын

    Very Nice Explanation.....Keep making videos

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Sure. Keep learning, Keep growing and keep loving Pepcoding!😊

  • @1991deeps
    @1991deeps3 жыл бұрын

    You should write continuous sub-array as this solution would not do for non-continuous sub-arrays.

  • @kishorchintalchere
    @kishorchintalchere3 жыл бұрын

    Best explanation 🔥🔥✌️✌️👍👌👌

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. If you like our efforts, we request a review g.page/Pepcoding/review?rc You can subscribe to our channel here kzread.infoabout?view_as=subscriber

  • @tanishkumar6682
    @tanishkumar6682 Жыл бұрын

    understood

  • @SumitSingh-ui4do
    @SumitSingh-ui4do2 жыл бұрын

    Great explanation ❤️🙏🙏🙏

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Glad it was helpful! Keep learning. And for better experience and well organised content visit nados.pepcoding.com

  • @sourvad
    @sourvad3 жыл бұрын

    Ah finally I get it, thanks!

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Keep learning and keep growing😊 If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

  • @sahilanand30
    @sahilanand302 жыл бұрын

    Best explanation

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    Glad you think so! For better experience and well organised content visit - nados.io

  • @KinnarKansara
    @KinnarKansara3 жыл бұрын

    Nicely explained!!

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Glad you liked it If you like our efforts, we request a review g.page/Pepcoding/review?rc You can subscribe to our channel here kzread.infoabout?view_as=subscriber For clearing your doubts, you can join our community on telegram t.me/pepcoding

  • @abhishekrai4325
    @abhishekrai43253 жыл бұрын

    Thank you sir ji 🙏❤️

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Keep learning, keep supporting

  • @codesherroads3629
    @codesherroads36293 жыл бұрын

    Sir can u start dsa course in c++

  • @mrprime557
    @mrprime5572 жыл бұрын

    Amazing !!!

  • @Pepcoding

    @Pepcoding

    2 жыл бұрын

    For better experience visit on nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/

  • @rajugoud6465
    @rajugoud64653 жыл бұрын

    Great work Bro..

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Thankyou beta! I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc

  • @RajeshKumar._.16
    @RajeshKumar._.16 Жыл бұрын

    nice

  • @sauravsemwal1346
    @sauravsemwal13463 жыл бұрын

    Sir , aapka explanation bhut bdiya hai... Video ke title me leetcode problem no. bhi dal do easily search me aayega.....

  • @Pepcoding

    @Pepcoding

    3 жыл бұрын

    Ji.

  • @moozaheed9568
    @moozaheed95682 жыл бұрын

    Love from BD

  • @nicolasjimenezgarcia9560
    @nicolasjimenezgarcia95602 жыл бұрын

    I didn't understand, is this video in English? :(

Келесі