Advertisement
Ankit_132

A

Oct 1st, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin>>n;
  10.  
  11.     string s;
  12.     cin>>s;
  13.  
  14.     for(int i=0; i+2<n; i++)
  15.     {
  16.         if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
  17.             return cout<<i+1<<"\n", 0;
  18.     }
  19.  
  20.     cout<<-1<<"\n";
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement