fork download
  1. /*
  2. Welcome to JDoodle!
  3.  
  4. You can execute code here in 88 languages. Right now you’re in the C++ IDE.
  5.  
  6.   1. Click the orange Execute button ▶ to execute the sample code below and see how it works.
  7.  
  8.   2. Want help writing or debugging code? Type a query into JDroid on the right hand side ---------------->
  9.  
  10.   3. Try the menu buttons on the left. Save your file, share code with friends and open saved projects.
  11.  
  12. Want to change languages? Try the search bar up the top.
  13. */
  14.  
  15. #include <bits/stdc++.h>
  16.  
  17. using namespace std;
  18.  
  19. int main() {
  20. string s,t;
  21. cin>>s>>t;
  22. unordered_map<char,int>mp1,mp2;
  23. for (int i=0;i<s.size();i++){
  24. mp1[s[i]]++;
  25. for (int i=0;i<t.size();i++){
  26. mp2[t[i]]++;
  27. int cnt=1e9;
  28. for(int i=0;i<t.size();i++){
  29. if(mp1.find(t[i])==mp1.end()){
  30. return 0;
  31. }
  32. int val=mp1[t[i]]/mp2[t[i]];
  33. cnt=min(cnt,val);
  34. }
  35. cout<<cnt<<"";
  36. }
  37. }
  38.  
  39. }
  40.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty