Yo are amazing! I can`t find any vedio explain the increasing sequence in such details like you. Just try to add a code and you will be the best among others :)
Thank you so much! Really appreciate your effort in explaining the algorithms in such depth. :) I usually watch your videos for the algorithms and it has helped me a lot.
Awesome Bhai.... You are great explaination... Many video I saw, but I understood this logic after watching your more iteration's example. :) Keep it up I do not need code, I can write as logic is understood.
Lots of thanks for your explanation. I did the code according it: public int lengthOfLIS(int[] nums) { int n = nums.length; int[] l = new int[n]; int[] idx = new int[n]; int max = 1; for (int i = 0; i < n; i++){ l[i]=1; int j = 0; while(j < i){ if (nums[i]>nums[j]){ int temp = l[j]+1; if (temp >= l[i]){ l[i]=temp; idx[i]=j; } } j++; } max = Math.max(max, l[i]); } return max; }
hello sir ....can you explain the recursive approach for the same problem ..i refered every site on internet but could not understand how the recursive solution is working...every body is just explaining the DP approach.
However we can have a maxLength variable to store max length at each iteration so we don't have to iterate through the array a second time to find the max length.
Thank you for such a nice video. But the algorithm is very time consuming with the time complexity of O(n^2). Could you please provide a better solution.
you dont even need a result array, you can keep two variables called maximum_seen_so_far, and length_of_subsequence, and as you iterate the loop, just update the two variables. That way the space complexity is O(1). Its still O(n^2) though. I suppose doing a binary search on a tree will make it O(h)? where h is height of the tree?
I think it would be nice if you explain why the index array behaves like you described, i.e., going backward works and discovers longest increasing array.
In the subseq array, what will be the previous element if there is no matching element at all. Ex: there is a 0 at 4th index a d there is no smallest elements for any j.
class Solution { public: unordered_map mp; int solve(vector nums, int last, int index){ if(index == -1) return 0; if(mp.count(index)) return mp[index]; if(nums[index] < last) mp[index] = max(1 + solve(nums, nums[index], index - 1), solve(nums, last, index - 1)); return solve(nums, last, index - 1); } int lengthOfLIS(vector& nums) { solve(nums, INT_MAX, nums.size() - 1); return mp[nums.size() - 1]; } }; Please debug this code, when I don't use DP this solution works when I store in DP array it don't work
Pseudo Code /* lis() returns the length of the longest increasing subsequence in arr[ ] of size n */ int lis( int arr[], int n ) { int lis[n] lis[0] = 1 /* Compute optimized LIS values in bottom up manner */ for (int i = 1; i < n; i++ ) { lis[i] = 1; for (int j = 0; j < i; j++ ) if ( arr[i] > arr[j] && lis[i] < lis[j] + 1) lis[i] = lis[j] + 1 } // Return maximum value in lis[] return *max_element(lis, lis+n) }
thank you bro
after watching 5 videos related to LIS
i came here and get a clear explanation thank you so much
I like your style, your explanations are much clearer than others'. Thanks!
Finally i found a proper explaination. Thanks 💖
Hats off of your videos! Clearly and neatly explained. Good job Vivek
Excellent explanation!! Thanks for making it easier to understand and making a complete video.
You are really great!! Thank you so much. No more words to express...You explained it the best way possible
sir i had watched more than 10 videos and read many blogs but i didnt understand...but now i understood :)
Thank you very much .
i did not understand in the class but you are the who help me to feel happy
i appreciate your effort
Yo are amazing! I can`t find any vedio explain the increasing sequence in such details like you. Just try to add a code and you will be the best among others :)
thank you so much! it was an excellent explanaition!
WOW, you gave the best explanation for LIS. All your lectures are super! Thanks lots!
Very beautiful explaination.thank you so much
Thanks Vivek for detail explanation. There is BST method (patience sort)to do same in O(n log n) time complexity. Kindly add that also.
WONDERFUL explanation sir !
This video helped me a lot👍
ur way of teaching is too easy to understand. Thank you , so much!
you actually teaches very well thanks for this video
Amazing best explanation i have seen so far.
Very thorough explanation. Pro tip: Watch at 1.5x speed :)
2x*
The best explanation I found so far!
Thank you so much! Really appreciate your effort in explaining the algorithms in such depth. :)
I usually watch your videos for the algorithms and it has helped me a lot.
Awesome video! All explained very carefully and clearly.
Your videos are great but include the code too if possible
write your own code!
excellent explanantion and hatsoof for ur tireless efforts ..worthy video compared to all other on this topic..keep continuing sir
Awesome Bhai.... You are great explaination... Many video I saw, but I understood this logic after watching your more iteration's example. :) Keep it up I do not need code, I can write as logic is understood.
awesome explanation sir, keep it up, thank you 👍👍👍👍🙂🙂
Thank you very much! So well explained.
one stop solution :) great way of teaching sir . thanks ❤
Lots of thanks for your explanation. I did the code according it:
public int lengthOfLIS(int[] nums) {
int n = nums.length;
int[] l = new int[n];
int[] idx = new int[n];
int max = 1;
for (int i = 0; i < n; i++){
l[i]=1;
int j = 0;
while(j < i){
if (nums[i]>nums[j]){
int temp = l[j]+1;
if (temp >= l[i]){
l[i]=temp;
idx[i]=j;
}
}
j++;
}
max = Math.max(max, l[i]);
}
return max;
}
awesome explanation, May God bless u sir :)
Awsome expaination...you are the Best..! it would be helpful if the code is included
Thank You So Much! This video was super helpful!
m-ai salvat de o restanta, mersi fain coaiemiu, ai o bere!!!
Thank you for the clear explanation!
Amazing!!! searched through many but this video is the one :)
Hello. Your video was very helpful. Just for about the creation of the sequence was not quite clear for me. Thanks.
Really good and clear explanation
Please can you make a video on O(nlogn) algorithm that can be used to solve this.
Thanks a lot, sir your videos are very good. One suggestion it will very helpful if you can put videos in the playlist in a sequence.
Excellent Explanation!!
hello sir ....can you explain the recursive approach for the same problem ..i refered every site on internet but could not understand how the recursive solution is working...every body is just explaining the DP approach.
Thank you ...best explanation...
Your explanation are best . But please try to include some sort of psedo code.
I think we can simply use a length variable instead of length array and assign the maximum value to the length variable in the outer Loop
No we cant. Because we need to store the length of the longest increasing subsequence up to each of the indexes. So we need the length array.
However we can have a maxLength variable to store max length at each iteration so we don't have to iterate through the array a second time to find the max length.
Thank you for such a nice video. But the algorithm is very time consuming with the time complexity of O(n^2). Could you please provide a better solution.
you dont even need a result array, you can keep two variables called maximum_seen_so_far, and length_of_subsequence, and as you iterate the loop, just update the two variables. That way the space complexity is O(1). Its still O(n^2) though. I suppose doing a binary search on a tree will make it O(h)? where h is height of the tree?
Great work!!! Appreciated
best explanation ever !
thank u so much sir.Could you please make a video on digit dp
This is O(n^2). Please explain O(nlogn) solution with patience sorting
Thanks Sir ! Learn a lot
Bruh, I can search for how to make apple pie or how to solve leetcode questions and bam, an Indian pops up with an explanation.
I think it would be nice if you explain why the index array behaves like you described, i.e., going backward works and discovers longest increasing array.
Hey Vivek it would be helpful if u can add the code snippet
thanks a lot bro... keep it up!!!
but how to compute time complexity of this algorithm
Please do video on Flattening a Linked List
LinkedList is already a flat data structure.
In the subseq array, what will be the previous element if there is no matching element at all. Ex: there is a 0 at 4th index a d there is no smallest elements for any j.
awesome sir
Very well done, thank you.
class Solution {
public:
unordered_map mp;
int solve(vector nums, int last, int index){
if(index == -1) return 0;
if(mp.count(index)) return mp[index];
if(nums[index] < last)
mp[index] = max(1 + solve(nums, nums[index], index - 1), solve(nums, last, index - 1));
return solve(nums, last, index - 1);
}
int lengthOfLIS(vector& nums) {
solve(nums, INT_MAX, nums.size() - 1);
return mp[nums.size() - 1];
}
};
Please debug this code, when I don't use DP this solution works when I store in DP array it don't work
Please do vedios on
Deletion of a node from AVL tree. And RedBlackTrees concept
Thank you so much!
👍👍
Sir could u plz explainthe C code how AVL tree insertion deletion happen
sir cant we just sort the array and then find longest common subsequence ???
Topological sort in a DAG, please.
Awesome logic!! Gr8 video.. tysm
i am watching this x2 speed.Can't understand what he is saying,but i understand the writings
can you make a video on XOR linked list,please?
really very good teach....
Code for the above Algorithm
in case you couldn't manage to write it by your self
void solve(int arr[], int n){
int lis[n];
int inde[n]; // one array will require to find the length of longest increasing subsequence
lis[0]=1;
for(int i=1;i
ty for your explanation sir
Can you please cover Length of Longest Fibonacci Subsequence problem?
Very helpful. Thanks :)
Nice video! Well explained.
Nice explanation.
Sir first off all how to choose the sequence plz tell me
Thank you sir
Great, thank you.
nice explanation ...
still the best explanation
Hello!!! Where did this guy go to?
where can i get exactly written code like this?
can you explain with code
thank u so much sir...
You're awesome 👌👌♥️
thank you so much
You are amazing
Thank You
🔥🔥🔥🔥🔥
sir, y aren't you making videos nowadays..?
Pseudo Code
/* lis() returns the length of the longest increasing
subsequence in arr[ ] of size n */
int lis( int arr[], int n )
{
int lis[n]
lis[0] = 1
/* Compute optimized LIS values in bottom up manner */
for (int i = 1; i < n; i++ )
{
lis[i] = 1;
for (int j = 0; j < i; j++ )
if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)
lis[i] = lis[j] + 1
}
// Return maximum value in lis[]
return *max_element(lis, lis+n)
}
Thankyou so much ✌
0,2,6,9,11,15 is the correct answer
so helpful .
Basile?
I don't know why my output is 15 13 9 6 4 0, somebody help
what is the time complexity of this algorithm?
O(n^2)
Thanks ;)
Multi threading red black tree please
very nice
Try to recite little fast