Untitled
unknown
plain_text
a year ago
278 B
7
Indexable
class Solution { public: int longestSubsequence(vector<int>& arr, int dif) { int res=1; unordered_map<int,int>mp; //initial value 0 for(int &i:arr){ mp[i]=1+mp[i-dif]; res=max(res,mp[i]); } return res; } };
Editor is loading...
Leave a Comment