fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. auto str = "helloWorld"s;
  9.  
  10. sort(begin(str), end(str));
  11.  
  12. for(auto start = adjacent_find(cbegin(str), cend(str)), finish = upper_bound(start, cend(str), *start); start != cend(str); start = adjacent_find(finish, cend(str)), finish = upper_bound(start, cend(str), *start)) {
  13. cout << *start << " = " << distance(start, finish) << endl;
  14. }
  15. }
Success #stdin #stdout 0s 4188KB
stdin
Standard input is empty
stdout
l = 3
o = 2