fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. int main() {
  6. std::string s;
  7. std::cin >> s;
  8.  
  9. int best = s.size();
  10. int prev = -1;
  11. int next;
  12.  
  13. while ((next = s.find_first_not_of("*", prev+1)) >= 0) {
  14. if (prev >= 0 && s[prev] != s[next]) {
  15. best = std::min(best, next - prev - 1);
  16. }
  17. prev = next;
  18. }
  19. std::cout << best;
  20. return 0;
  21. }
Success #stdin #stdout 0s 16048KB
stdin
A*A**B***A**
stdout
2