Company: Swiggy_16oct
Difficulty: medium
Mirror personalities Problem Description A town has N residents whose houses stand in a single row. Every resident has a personality, written as one lowercase English letter, so the whole town is described by a string S of length N , where S[i] is the personality of the resident in house i (0-based). Write the alphabet in order, A = "abcdefghijklmnopqrstuvwxyz" , and write it backwards underneath, B = "zyxwvutsrqponmlkjihgfedcba" . The mirror of a letter is the letter directly below it: the letter of B at the same position as the letter in A . So 'a' and 'z' are mirrors of each other, 'b' and 'y' are mirrors, 'c' and 'x' are mirrors, and so on up to 'm' and 'n' . No letter is its own mirror. Two residents get into a fight when their personalities are mirrors of each other. Find how many pairs of residents fight. A pair is unordered: the pair (i, j) is the same as the pair (j, i) , and it is counted once. Write a function solution(N, S) that returns the number of fighting pairs. Input F