


If we are given a string ‘aabb’.Then we can see the frequency of a=2 and b=2. The position of ‘a’ in alphabets is 1 and the position of ‘b’ is 2. So ‘a’ has an even frequency but its position is odd, so it will not contribute to M. As ‘b’ has an even frequency and its position is also even, so M=1. Now M =1 which is odd, so we have to return “ODD”.
The first line of input contains a single integer 'T', representing the number of test cases. The 'T' test cases follow.
The first and only line of each test case contains a string 'STR'.
For each test case, print “EVEN” if M is even, else return “ODD” without quotes.
You don’t have to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N <= 10 ^ 4
Time limit: 1 sec
We will find the frequency of all characters by iterating over the whole string 26 times. On completion of iteration if the frequency of character is odd and the position of the character is odd, increase M by 1, otherwise if the frequency of character is even and the position of the character is even, increase M by 1.
We will scan the string from left to right and we will use the Hash to store the frequency of each character.
We generally have INT of 4 bytes or we can say 32 bits. So we are going to use the bits of INT to store the frequency of characters. We are going to use two integers for the purpose say EVEN and ODD.
As for odd positions we just need to check if the frequency is odd or not, the corresponding bit will be 0 initially and we will XOR the bit on encountering the character. And in last if the bit is 1 we can say we have an odd frequency.
As for even positions we just need to check if the frequency is even or not, the corresponding bit will be 0 initially and we will XOR the bit on encountering the character. And in last if the bit is 0 we can say we have an even frequency, with one exception when the frequency is 0, also then the final bit will be zero. So we need to make sure that at least frequency is greater than 1.