00:08 Understanding the Max Chunks To Make Sorted problem on LeetCode. 02:09 Understanding partitioning for sorting in Leetcode 769. 04:09 Determining valid partition points in a sorted array. 06:16 Understanding partition points for sorting permutations. 08:17 Maximize partitions based on anagram groups effectively. 10:17 Partitioning an array requires max left to be less than min right. 12:24 Understanding block creation for array partitioning based on maximum values. 14:26 Creating partitions by tracking maximum values in the array. 16:23 Counting anagrams through an efficient linear time approach.
Another intuitive approach is to compare the prefix sums of the given array and the fully sorted array at each index. If they are the same, it means a new chunk can be created.
thanks sir 🤗 small request can you please provide a small post or a code block in which we can refer the brute force approach just to the understand in more depth about the solution ....
class Solution { public: int maxChunksToSorted(vector& arr) { int chunk=0; int sum1=0,sum2=0; int i=0; for(auto x:arr){ sum1+=i; sum2+=x; if(sum1==sum2){ chunk++; } i++; } return chunk;
00:08 Understanding the Max Chunks To Make Sorted problem on LeetCode.
02:09 Understanding partitioning for sorting in Leetcode 769.
04:09 Determining valid partition points in a sorted array.
06:16 Understanding partition points for sorting permutations.
08:17 Maximize partitions based on anagram groups effectively.
10:17 Partitioning an array requires max left to be less than min right.
12:24 Understanding block creation for array partitioning based on maximum values.
14:26 Creating partitions by tracking maximum values in the array.
16:23 Counting anagrams through an efficient linear time approach.
👌🏽
Thank you teacher, your explaination is very excellent to approach!
welcome :)
Another intuitive approach is to compare the prefix sums of the given array and the fully sorted array at each index. If they are the same, it means a new chunk can be created.
yepp :)
Thank you sir !!!!!!!!!!!!!!!!!!!!!!!!!!
Understood 100%
great 👍🏼
thanks sir 🤗
small request can you please provide a small post or a code block in which we can refer the brute force approach just to the understand in more depth about the solution ....
that would be too much for me 🥵
You can try and share your issue if you get
class Solution {
public:
int maxChunksToSorted(vector& arr) {
int chunk=0;
int sum1=0,sum2=0;
int i=0;
for(auto x:arr){
sum1+=i;
sum2+=x;
if(sum1==sum2){
chunk++;
}
i++;
}
return chunk;
}
};
👍🏼
Thank you sir :)
welcome :)
Excellent explanation
thanks :)
I really liked this video❤
nice :)
Using max-heap
class Solution {
public:
int maxChunksToSorted(vector& arr) {
int ans = 0 ;
int val = 0;
priority_queue pq;
for(int i= 0 ; i < arr.size(); i++){
pq.push(arr[i]);
if(!pq.empty() && val==pq.top()){
ans++;
while(pq.empty()) pq.pop();
}
val++;
}
return ans;
}
};
Min-heap
sahi hai bhai...bas while(pq.empty()) ke jagah while(!pq.empty()) aayega shyd
@@subratamandal2924 its max-heap
@@subratamandal2924 yaa my bad !