Source Code
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int min = n;
	for (int i = 0; i < n; ++i){
		for (int j = i; j < n; ++j){
		    if(s[i] == s[0] && s[j] == s[n - 1]){
		        min = j - i + 1;
		    }
		}
	}
	cout << n - min << endl;
	return 0;
}
Copy
Pop Pop Hiexy
GNU G++17
0 ms
360 KB
Wrong Answer