Range Sum of Sorted Subarray Sums - Leetcode 1508 - Python

preview_player
Показать описание


0:00 - Read the problem
0:30 - Drawing Explanation
2:44 - Coding Explanation
5:57 - Drawing Explanation 2
11:48 - Coding Explanation 2

leetcode 1508

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

love the advice on don't bother with this if you are preparing just for interviews. Thank you! I'd have probably lost a day on that editorial!

Thank you NeetCode!

business_central
Автор

just wanted to say your videos are extremely easy to understand. i've used your channel for hard daily leetcode questions in the past, and you make it alot easier. i liked your realistic comments in this video as well.

ursalight
Автор

"don't ask me how to come up with it. I think that's a question for God to be honest" - best moment of today's video. And I completely agree.

MykolaPavluchynskyi
Автор

i spent 3-4 hrs on editorials and claude trying to understand and nothing made sense until now

parthdeshwal
Автор

i am preparing for interviews and i came across monotonic stack and queue questions and started banging my head against the wall learning these concepts and trying to solve the questions. I am wondering if Amazon/Google do ask these questions on the final loops especially the amazon final loop

bombrman
Автор

I made the subarray_sums, then heapified it, and then popped "right" elements, I summed up the last "left" elements and returned it.
Overall for a time complexity of n^2 + right*log(n^2) = n^2*log(n) but if right is a small number it's more efficient

michaelroditis
Автор

pretty simple problem once you understand the description and separate it into manageable chunks :)

ky.castillo
Автор

Today's daily challange was asm !! i came to learn something new! thanks for explaining

johnj
Автор

Hey Neetcode! Thank you for doing the daily Questions it really helps!

adityamallik
Автор

a question, I understand we have to mod every sub array sum, but why are we modding the sub array sum again when adding it to the final result? this is not asked in the question.

mayankpant
Автор

I think there's a problem with your first solution. Using that modulo while creating the sums array would break the sort of the numbers were large enough. The only reason it works still is that the sub array sums will never become that large.

Codisrocks
Автор

There is also an approach to get n^2 solution. C++ has a convenient std::nth_element which easily removes the need for full sort. I'm sure counting sort also works here

greatfate
Автор

I first did the N²LogN then came to see the optimized approach by Neetcode and got the treat

ramvishnu
Автор

Hey @NeetCodeIO can you please do an episode on range module LC#715? Trying to understand segment trees and was looking for the Neetcode version. Best explained leetcode ever!! thank you so much for all you do!

sreenivaskrishna
Автор

This problem is similar to merge k sorted list.

akashverma
Автор

I have done it with help of recursion.
Time complexity = O(NlogN)
Space complexity = O(N)
Is it optimal?

debangshudey
Автор

I closed the editorial after seeing the sliding window + binary search soln

ashishk
Автор

People are here for the binary search approach

vaibhavbansal
Автор

i was here for boinary search solution not this onw

Mad_Monk
welcome to shbcf.ru