Company: Swiggy_9dec
Difficulty: medium
Mirror Personalities Problem Description N people live in a town and their 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 their own. Let the alphabet string A be "abcdefghijklmnopqrstuvwxyz" and let B be the reverse of A, that is "zyxwvutsrqponmlkjihgfedcba" . The mirror of any character of A is the character at the same index in B. The mirror of 'a' is 'z' . The mirror of 'b' is 'y' . The mirror of 'c' is 'x' , and so on. Given the personality of every person in the town as a string S of length N , determine the total number of pairs of residents who are in a fight. Note: a pair (i, j) is the same as the pair (j, i), so each unordered pair is counted exactly once. A person is never in a fight with himself. Function Description Complete the function countFightingPairs() . It takes the following 2 parameters and returns the answer: N : an integer