fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.  
  9. int freq[26]{};
  10.  
  11. int n;
  12. cin>>n;
  13.  
  14. char c;
  15.  
  16. bool AllColored = false;
  17.  
  18.  
  19. // aabddc
  20. for(int i=0; i < n ; i++)
  21. {
  22. cin>>c;
  23. freq[c - 'a']++;
  24. }
  25.  
  26. // 0(a) 1(b) 2(c) 3(d)
  27. // 2 1 1 2
  28.  
  29. // for(int i = 0; i<26; i++)
  30. // {
  31. // cout<<freq[i]<<endl;
  32. // }
  33.  
  34. for(int i=0; i<26; i++)
  35. {
  36. if(freq[i] >= 2 || n == 1)
  37. {
  38. AllColored = true;
  39. break;
  40. }
  41. }
  42.  
  43. if(AllColored)
  44. {
  45. cout<<"Yes";
  46. }
  47. else
  48. {
  49. cout<<"No";
  50. }
  51. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
No