excellent video....learnt very new approaches...appreciate your hardwork...keep on making such videos
@instinct1098Күн бұрын
sliding window solution was too good! I had approach for sliding window but didn't think to sort the array as it was asked to for subsequence so I thought that sorting will ruin it. None the less great explanation and intuition on both the approaches!!
@LinhHoang-ml1qoКүн бұрын
Thank you a lots
@spaaclub5212Күн бұрын
Good solution keep posting like this bro...!
@ARYANMITTALКүн бұрын
Agar accha lage toh ek payara sa like bhej dena 🫂❤
@Nutrino259Күн бұрын
For those who didn't get the intuition of Prefix Sum approach, it is a simple Line sweeping method of greedy topic. Learn that and you will be solving many questions based on some intervals.
@ajayc815Күн бұрын
Much appritiated
@lazyemperor5182Күн бұрын
bhai use descriptive variable names, i, j ki wajah left, right use karo. People will also get used to writing readable code. It will be more clear to understand too.
@lakshmisaichaitanyarajapu9313Күн бұрын
HI Aryan, jsut a small doubt, if they are asking for " length of the longest subsequence", how are we sorting, which will disturb the sequence order
@ssathwik6586Күн бұрын
after sorting we are finding for equal elments what will happen if they are anywhere in the line length of subsequence toh same hoga na
@vukanoaКүн бұрын
That is the "trick" of this whole Sliding Window Solution. You have to figure that out. Subsequences usually are for "longest chains" or "increasing order" or something like that in which case we indeed must not disturb the sequence order. However, in problems like this where it's only asked: "What is the longest *frequency* after the merge of all the ranges?" Then the "subsequence" part doesn't matter, therefore we can disturb the order. Consider this: nums = [1,2,1,3,1,7] If we were asked to find a longest subsequence that is in increasing order, we indeed wouldn't have a permission to disturb the sequence order. The answer would be 4. The subsequence would be: {1,2,3,7} However, if we were asked: "What is the longest subsequence of *equal values* ?" Then it wouldn't matter. Look at it: nums = [1,2,1,3,1,7] // For this order, the answer would be 3. nums = [1,7,2,3,1,1] // For this order, the answer would ALSO be 3, even if we've distrubed the order. Hope this helps. Edit: small mistakes.
@LinhHoang-ml1qoКүн бұрын
well, you know when you achieve your target,many elements which you choose for your maximum length of answer will equal other.So exchange their order doesn't make any sense.For example: [1 2 1 3 1] : max length here is 3 after do many operation(assum),if you change order of elements with value 1, you still got your answer is 3.Hope it can help you!
@ahappyperson6530Күн бұрын
order doesn't matter, our target is to return number of elements, and not to return the order of their indices
@Munchen888Күн бұрын
I think can we use hashmap[num - k] and hashmap[num + k]. 😅