Codeforces Round 872 (Div. 2) 1825A - LuoTianyi and the Palindrome String Solution
Problem Link : https://codeforces.com/contest/1825/problem/A
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- string s ;
- cin >> s ;
- set<char>st;
- for ( int i = 0 ; i < s.size() ; i++) {
- st.insert(s[i]);
- }
- if (st.size()== 1 ) cout <<"-1\n";
- else cout <<s.size()-1 <<"\n";
- }
- }
No comments