| 19 | return 0; |
| 20 | } |
| 21 | void solve() |
| 22 | { |
| 23 | string str; |
| 24 | cin>>str; |
| 25 | int arr1[26], arr2[26]; |
| 26 | memset(arr1,0,sizeof(arr1)); //initialising all the array elements with 0 |
| 27 | memset(arr2,0,sizeof(arr2)); //initialising all the array elements with 0 |
| 28 | for(int i=0;i<str.length()/2;i++) //for first half of the string |
| 29 | { |
| 30 | arr1[int(str[i]-'a')]++; // int(str[i]-'a') converts the character into respective integer depending upon its position |
| 31 | } |
| 32 | int j=str.length()/2; |
| 33 | if(str.length()%2==1) //if length is odd then we need to skip a character |
| 34 | ++j; |
| 35 | for(;j<str.length();j++) |
| 36 | { |
| 37 | arr2[int(str[j]-'a')]++; // int(str[i]-'a') converts the character into respective integer depending upon its position |
| 38 | } |
| 39 | for(int i=0;i<26;i++) |
| 40 | { |
| 41 | if(arr1[i]!=arr2[i]){ //if mismatch in frequencies then print "NO" |
| 42 | cout<<"NO\n"; |
| 43 | return; |
| 44 | } |
| 45 | } |
| 46 | cout<<"YES\n"; //if frequencies remain same till now then print "YES" |
| 47 | } |