Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int SubsequenceLength (string s)
- {
- int mp[26]={0};
- int i,j=0;
- int cnt=0,maxx=0;
- for(i=1;i<=s.length();i++)
- {
- if(mp[s[i-1]-'a']>j)
- {
- j=mp[s[i-1]-'a'];
- }
- mp[s[i-1]-'a']=i;
- maxx=maxx>(i-j)?maxx:(i-j);
- }
- return maxx;
- }
Add Comment
Please, Sign In to add comment