Agar accha lage toh ek payara sa like bhej dena 🫂❤
@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!!
@viralshah316Ай бұрын
liked sliding window approach
@LinhHoang-ml1qoАй бұрын
Thank you a lots
@user-bt6mh9ez3uАй бұрын
excellent video....learnt very new approaches...appreciate your hardwork...keep on making such videos
@spaaclub5212Ай бұрын
Good solution keep posting like this bro...!
@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
@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.
@batmanwhocodesАй бұрын
you didnt explain BS soln
@Munchen888Ай бұрын
I think can we use hashmap[num - k] and hashmap[num + k]. 😅
@lovelyhari9059Ай бұрын
Aryan dont use red colour it very dim and annoying use any bright colour pen thickness little bit more pls