Advertisement
Ahmed_Negm

Untitled

May 6th, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. set<char>st;
  2. ll n; cin>>n;
  3. string s; cin>>s;
  4. ll x; cin>>x;
  5. vector<int>v;
  6. while(x--){
  7. char z; cin>>z;
  8. st.emplace(z);
  9. }
  10. for(auto i = st.begin(); i!= st.end(); i++){
  11. v.push_back(s.rfind(*i));
  12. }
  13. sort(rall(v));
  14. int differ;
  15. if(sz(v) == 1){
  16. if(v[0]<=0) {
  17. cout<<0<<nl;
  18. return;
  19. }else cout<<v[0]<<nl;
  20. }
  21. for(int i=0; i<sz(v)-1;i++){
  22. differ = v[i]-v[i+1];
  23. }
  24. differ = min(differ,v[sz(v)-1]);
  25.  
  26. // for(auto&h:v) cout<<h<<' ';
  27.  
  28. cout<<nl;
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement