Given a string s, find the number of pairs of characters that are same. Pairs (s[i], s[j]), (s[j], s[i]), (s[i], s[i]), (s[j], s[j]) should be considered different.
INPUT: The first line consists of an integer T i.e. the number of test cases. Each test case has the single line input, denoting the string s.
OUTPUT: Print the total number of pairs in the string.
1<=|Length of string|<=105
Input: air Output: 3 Explanation : 3 pairs that are equal are (a, a), (i, i) and (r, r) Input : geeksforgeeks Output : 31
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.