2779. Maximum Beauty of an Array After Applying Operation | Prefix Sums | Sliding Window

  Рет қаралды 1,797

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 16
@viralshah316
@viralshah316 Күн бұрын
liked sliding window approach
@user-bt6mh9ez3u
@user-bt6mh9ez3u Күн бұрын
excellent video....learnt very new approaches...appreciate your hardwork...keep on making such videos
@instinct1098
@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
@LinhHoang-ml1qo Күн бұрын
Thank you a lots
@spaaclub5212
@spaaclub5212 Күн бұрын
Good solution keep posting like this bro...!
@ARYANMITTAL
@ARYANMITTAL Күн бұрын
Agar accha lage toh ek payara sa like bhej dena 🫂❤
@Nutrino259
@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
@ajayc815 Күн бұрын
Much appritiated
@lazyemperor5182
@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
@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
@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
@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
@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
@ahappyperson6530 Күн бұрын
order doesn't matter, our target is to return number of elements, and not to return the order of their indices
@Munchen888
@Munchen888 Күн бұрын
I think can we use hashmap[num - k] and hashmap[num + k]. 😅
@vijaybenz1807
@vijaybenz1807 Күн бұрын
you didnt explain BS soln
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 13 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 26 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 755 М.
Building Real-time Apps with Go | Azim Pulat
54:58
Azim Pulat
Рет қаралды 41 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 13 МЛН