Subarray Sum Equals K || Leetcode 560 || 2 Variant Questions Big Tech Actually Asks

preview_player
Показать описание
Discover the actual variants Meta asks on Leetcode problem 560: Subarray Sum Equals K.

Timestamps:
00:00 Leetcode Explanation
19:42 Leetcode Coding
21:10 Variant #1 Explanation: True or False?
24:48 Variant #1 Coding: True or False?
25:55 Variant #2 Explanation: Only Positive Numbers
30:11 Variant #2 Coding: Only Positive Numbers

Follow us on social media:

GitHub:

More Context:
FAANG, mid-sized companies, and startups are asking more LeetCode-style puzzle questions every day, making it harder to stand out as the competition grows. With an increasing number of new graduates entering the software market and tech companies laying off developers while overworking those who remain, it’s a tough landscape. Take Meta, for example: they expect 2-3 months of intense study time, only to likely ghost you afterward. But this doesn’t mean we should be unprepared.

While LeetCode is a valuable learning resource, many developers focus too much on rote memorization. Others find themselves stuck in a vicious cycle, where they don’t study as efficiently as they could because they’re juggling multiple responsibilities. They have full-time jobs, personal commitments, or other obligations that limit the time they can dedicate to solving problems. It’s a grind. Unfortunately, most companies introduce their own twists or "variants" of common problems (e.g., 6-sum instead of 2-sum), which throw candidates off. Rephrasings of problems and follow-up questions are also common, so recognizing these variations and curveballs is crucial.

For those who don’t have the time to revisit LeetCode problems multiple times to solidify concepts, this channel covers the most frequently asked variants, rephrasings, and follow-ups. If you've seen these before, you’ll have a significant edge over your competitors. Remember, time pressure — especially at Meta — is intense, so speed is essential. Even with thorough preparation, interviewers may be unpredictable, but knowing the variants beforehand can drastically increase your chances of success.

Take LeetCode 560, Subarray Sum Equals K, which is one of Meta’s most frequently asked questions (top 20 as of writing). Meta sometimes sticks to the original problem. Variants - however - do exist, and with thousands of interviewers, it's hard to predict them all. We cover 2 key variants: one, what if you had to return true if there is at least one subarray sum that equals K? And two, what if you were given only positive numbers - does your algorithm change?

We also walk through variants in mock interviews. Using the exact platform (CoderPad) that Meta uses, you’ll get familiar with the UI, settings, and overall experience. This is a 1-on-1 simulation of how Meta conducts and facilitates their interviews, so the goal is to avoid wasting time on the tool itself. Once again, time limits at Meta are a huge factor, so speed is critical.

That said, even with perfect preparation, interviewers might not always be in a good mood or may judge unfairly. The interview process has its power dynamics, but with insider knowledge, you’ll have done as much as you can on your end to secure a Strong Hire decision.
Рекомендации по теме
Комментарии
Автор

Thank you for putting this together, and I really appreciate the examples you chose and your ability to take the time to walk through them. I've done this problem a few times in the past, and felt pretty confident in it, but I couldn't get it to stick well enough to explain it with confidence. The examples you chose and the walkthrough finally connected the missing links for me. I probably would have been fine if I was given the question in an interview before I watched this vid, but now I know I will do well and having that confidence can really make the difference.

I've put off watching some of your videos because I've been like, "meh, I pretty much know how to do that already", but now after watching this one I'm definitely going to spend the time to go back and watch the ones I skipped over.

Thank you!

oliveroliver
Автор

Watched 5-6 different videos, no one explained it better than you. Great examples as well. Thanks a lot

hasson
Автор

finally after going over chatpgpt, 4-5 videos and the editorial of Leetcode in vain i finally understood why not sliding window, or set. Thank you!

leafylemn
Автор

This is the best explanation for this question that I've come across. The dry run walk through finally made sense to me and I appreciate you explaining why a hash-map is needed over the hash-set.

kavan
Автор

Thank you for making this video long to take the time to explain this in detail. This problem has been melting my brain the last couple days. I subscribed and look forward to watching more of your videos

playfuss
Автор

These videos are super helpful. Really like how you discuss the trade offs between different techniques. One golden problem that’s strikes a lot of debates is Top k Frequent elements. Never fully understood how to explain it. Would be really helpful if you can cover it!

Thanks for the good work.

anjulmishra
Автор

I just paused the video because I couldn't get this off my head: How come some people like Minmer are so devoted, so nice and politely helping people pursue a life changing career. If he wanted to do this just for money, he sure could earn more as a SDE. I feel guilty for not having this devotion and enthusiasm.

vahidsaber
Автор

@Coding with Minmer i was asked the second variant in meta phone screening, thanks for your videos .

amruthamishra
Автор

Holy Shit I just got the second variant and solved it without watching this video or doing it ooff guess practice does pay off, watched many thanks Minmer!

ezio
Автор

Thanks so much for all of these videos! Currently preparing for the Meta phone screen and having the variants is super helpful 💪

One question, do you have a list of common variants/follow ups outside of the videos themselves? I see your comments on leetcode when I'm looking for variants so I figure you might have a more complete list elsewhere. No worries if not, I'll definitely be watching upcoming videos anyway!

saladtrayend
Автор

This is a very good problem and explanation. Like many I also attempted to use a sliding window and learned a lot when it failed. I think another cool variant is to return the actual subarrays instead of just the count.

shawnallenstrausser
Автор

i always find the example in your video is very important to reveal edge cases. When you prepare you solution, how did you come up with your example array? do you have to do multiple tries to get the right example? of course, i know you have to know the edge cases first to be able to come up with a good example that's representative enough...
For me, it's hard to come up with an example within a tight time, especially in an interview....

tracyshen
Автор

Hey Minmer! Do Meta interviewers have a gauge on how difficult the question they gave you was? For example would they be a little bit more lenient on Accounts Merge? I thought I saw you mention that on a Reddit post.

castleridgelabs
Автор

In variant 3 if i have to calculate how many such subarrays are there, we need to then start the ith pointer on every index and try sliding window from each index right ?

TechieTech-gxkd
Автор

Great video!! thanks for making them!!

For the positive variant, before checking your code solution I came up with this one, that I think it works, but I'm not 100% sure since the sliding windows was new to me, any thoughts?

def sub_sums_positive(nums: list[int], k: int) -> bool:
L, R = 0, 0
aux = 0
while L < len(nums) and R < len(nums):
aux += nums[R]
if aux == k:
return True
if aux < k:
R+=1
elif aux > k:
aux -= nums[L]
aux -= nums[R]
L+=1

return False

Thank you again!!

paulcruz
Автор

Would the sliding window method get you the count as well?

serein
Автор

why are we checking compliment subarray??
If we have a curr prefix sum a subarray of X, and we know we need subarray of K, then if we have a compliment subarray of X - K, then we found a valid subarray.

??? why

ObtecularPk
Автор

for the second variant you dont need to sort the array?

RacleandRaHill
welcome to shbcf.ru