Question 3: Mirror Personalities
Problem Statement
N people live in a town. The houses are arranged in a row. The personality of each owner is represented by a lowercase English character. Each person is in a fight with all those people who have a mirror personality to the one in the fight.
Let A be the string "abcd...yz". Let B be the reverse of string A, i.e., "zyx...ba". The mirror of any character from string A is the character in the same index in string B.
* Reverse of 'a' is 'z'.
* Reverse of 'z' is 'a'.
* Reverse of 'x' is 'c'.
Given the personality of each person in the town, determine the number of pairs of residents who are in a fight.
Note: Pair (i, j) is the same as (j, i).
Input Format
* The first line contains N denoting the length of the string.
* The second line contains S denoting the input string (personalities).
Output Format
* Return an integer denoting the number of mirror pairs.
Constraints
* * S[i] is a valid small case English character.
Sample Input
3
aaz
Sample Output
2
Explanation
Considering 0-based indexing:
* Person at index 0 is 'a'. Mirror is 'z'. Person at index 2 is 'z'. Pair (0, 2) is valid.
* Person at index 1 is 'a'. Mirror is 'z'. Person at index 2 is 'z'. Pair (1, 2) is
valid.
* Total pairs: 2.