i think of a better solution let us say m1-m2 =diff then m1-diff =m2 this means if we use a map and find the m2 element in the map we increase its frequency (curr-diff)+1 else we initialize it to one and just store the count of element with maxfreq in an variable and return it . Here is the code class Solution { public int longestSubsequence(int[] arr, int difference) { Map map=new HashMap(); int mx=0; for(int i=0;i
Wow very simply and beautifully explained!
So nice this lecture sir
Thank you! 💓
i think of a better solution let us say m1-m2 =diff then m1-diff =m2 this means if we use a map and find the m2 element in the map we increase its frequency (curr-diff)+1 else we initialize it to one and just store the count of element with maxfreq in an variable and return it .
Here is the code
class Solution {
public int longestSubsequence(int[] arr, int difference) {
Map map=new HashMap();
int mx=0;
for(int i=0;i
Doing Good Brother.. Keep going!
Thank you! ❤️
Which text editor you use for writing?
Its GoodNotes
Found the same problem a while ago but with limitations like this 2 < n < 10000, 1
This lecture is very nice sir
Thank you! 💓
really nice explanation please if possible make a video on all the imp patterns in arrays thanks ❤❤
Sure. I am planning to come up with a course! Stay tuned! Welcome❤️
Very smart solutions. Thank you.
I am glad you liked it!
thanks for the explanation
Welcome!❤️
very nice explanation bro😊
Thank you! 💓