Max Chunks To Make Sorted - Leetcode 769 - Python

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


0:00 - Read the problem
0:30 - Drawing Explanation
9:27 - Coding Explanation

leetcode 769

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

Half the difficulty of this problem is just understanding wtf it's asking

mechano
Автор

This channel is like a reverse rubber duck. Sometimes just listening about the problem, while having it all understood, helps to formulate a solution.

floriankubiak
Автор

Hey please don't stop making the leetcode daily video. U Know when u uploads the video I use to be able to try the problem with full confidence that ok if there would be a problem then in the end I can have the best solution.

tejas
Автор

Thank you for critizing leetcode’s English. It makes two times harder a regular question. Question is harder than solution many times.

PanicAtProduction
Автор

Very beautifully explained. Thank you. Missed your videos for a while there.

MP-nyep
Автор

The max jump solution is crazyy!!, never could have thought of that!!

pruthvinarayana
Автор

class Solution(object):
def maxChunksToSorted(self, arr):
res = 0
for i in range(len(arr)):
if sum(arr[:i]) == (i * (i-1))//2:
res += 1

return res

albin_joby
Автор

I thought I solved this in the most intuitive way but damn this prefix sum is soo much better

perezukaonu
Автор

You should make a video regarding competitive programming and explain what it is to those who don't even know what it is. I know you yourself have never really done competitive programming, so it would be interesting to see your take on some codeforces / atcoder problems. Given than leetcode is basically a rudimentary introduction into competitive programming.

gamingbutnotreally
Автор

My logic was simple, if 4 is at 0th index then what it is doing there
It should have been at 4th index so it means that we got single chunk from [0, 4]
But all items in range [0, 4] should be in range [0, 4]
If any item x > [0, 4] then new range becomes [0, x]
And this range expansion continues till we get a range where all items are within that range
So keep iterating from i to max where initially max = arr[i] and this will make sure that x > [s, e] then max updates to x and we keep iterating till x and hence we found 1 chunk

devkumar
Автор

i did it by sorting and 2 ptrs and now its time to see ur solution if there is any more optimized solution better than nlogn

tejas
Автор

To me at least this problem seemed similar to Leetcode 763 (Partition Labels), which is part of the NC150. I used that as my inspiration for solving this.

Автор

Great explanation! I love your channel.

LeonLeonLeonardo
Автор

Can we determine the number of decreasing sequences?

MrEngineer-di
Автор

Hey Neetcode, I am your pro subscriber. when are you going to release object oriented programming course?

RupeshPatel-ryjb
Автор

I found this one really hard, even after watching the explanation it just isn't "clicking" for me

teccs
Автор

hi, is there any way I can contact you?

mehdiamiri
join shbcf.ru