fork download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. map<int,string> words = {{1,"seeks"},{2,"seek"},{3,"kite"},{4,"eleas"}};
  8. map<char,int> occurstart,occurend;
  9. for(int i=1;i<=4;i++)
  10. {
  11. occurstart[words[i][0]]++;
  12. occurend[words[i][words[i].length()-1]]++;
  13. }
  14. for(map<char,int>::iterator iterstart = occurstart.begin(),iterend = occurend.begin();
  15. iterstart!=occurstart.end();iterstart++,iterend++)
  16. {
  17. cout << iterstart->first << " -> " << iterstart->second << "---" <<
  18. iterend->first << " -> " << iterend->second <<endl;
  19. }
  20.  
  21. for(map<char,int>::iterator iterstart = occurstart.begin();iterstart!=occurstart.end();iterstart++)
  22. {
  23.  
  24. if(occurend.find(iterstart->first)->second !=iterstart->second)
  25. { cout << "Not possible"; return 0;}
  26. }
  27.  
  28. cout << "Possible";
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
e -> 1---e -> 1
k -> 1---k -> 1
s -> 2---s -> 2
Possible