Subarray Sum Equals K (LeetCode) | Interview Question Explanation
Vložit
- čas přidán 5. 07. 2024
- Link to the Code: gist.github.com/JyotinderSing...
Link to the question: leetcode.com/problems/subarra...
Link to my GitHub: github.com/JyotinderSingh
Link to my Website: jyotindersingh.com/
Timestamps:
00:00 - Problem Introduction
01:33 - Algorithm Explanation - i
06:07 - Algorithm Explanation - ii
08:20 - Code Explanation
Algorithm:
- Iterate through the array while maintaining a running sum of the elements of the array
- At every element, check whether (runningSum - k) has already been encountered before or not (use a hashmap to keep track of this)
- If it has occurred before, add the number of previous occurrences to the result.
- Add the runningSum to the hashmap for possible future lookup
Be sure to drop a like and hit the subscribe button if you liked this video!
_______________________________________
Some great channels to learn more:
Tushar Roy: / tusharroy2525
Errichto: / @errichto
Nick White: / @nickwhite
Kevin Naughton Jr: / @kevinnaughtonjr - Věda a technologie
You just brought back the dead coder in me back to life!! I'm THAT inspired!! ... Plus you made it really easy to follow 👌 hat's off 💯
Ahahaha thanks for the support fam ♥♥♥