Nathan is a Researcher in English Literature. According to him string which when split in the middle, gives two halves having the same characters and the same frequency of each character is termed as Lapindrome.
If there are an odd number of characters in the string, the middle character needs to be ignored and to be checked for lapindrome. can you find the lapindrome strings?
Input:
The first line of input contains a single integer T, the number of test cases.
Each testcase is a single line containing a string S composed of only lowercase English alphabet.
Output:
For each test case, output on a separate line: if the string is a lapindrome print "YES" otherwise print "NO".
#include <stdio.h> #include<string.h> int main() { int i=0,T=0; scanf("%d",&T); for(i=0;i<T;i++){ int arr1[26],arr2[26]; memset(arr1,0,26*sizeof(int)); memset(arr2,0,26*sizeof(int)); char S[20];scanf("%s",S); int j=0,k=strlen(S)-1,flag=0; while(j<k){ arr1[S[j]-'a']++; arr2[S[k]-'a']++; j++; k--; } for (j=0;j<26;j++){ if(arr1[j]!=arr2[j]){printf("NO\n");flag=1;break;} } if(flag==0){printf("YES\n");} } return 0; }
INPUT_1:
6
gaga abcde rotor xyzxy abbaab ababc
OUTPUT:
YES
NO
YES
YES
NO
NO
INPUT_2:
5
ghfgh malayalam gogo roor caffac
OUTPUT:
YES
YES
YES
YES
YES
ILLUSTRATION:
Morae Q!
- Convert seconds to hours – HMS format.
- Find out the tax amount of the bill with tip for the meal.
- Find the area of the pyramid.
- Find the area of triangle using heron’s formula.
- Find the interest and amount resided in the bank.
- Convert the travel days to years and months.
- Find the first three powers of N number.
- Compute the height from feet and inches to centimetres.
- Calculate the amount of interest earned in the bank.
- Find the ways they can choose the sequence of dummy statues.
- Find the Lapindrome strings.
- Classify the salary of a person.
- Find the day on providing the week number.
- Find the least number of marble stones needed to pave the square mall.
- Find the number of steps on chessboard performed to satisfy a condition.
- Find the time, hours and minutes the train was delayed.
- Find the quantity of food packets shared and available.
- Compute all Arithmetic Operations.
- Find the amount to pay for the electricity bill.
- Find the sum of numbers with three values after decimal point.