Company: Amazon_july
Difficulty: medium
Word Conjugates Problem Description Amazon has introduced an innovative tool to explore the fascinating world of "Word Conjugates", allowing users to analyze strings consisting of only characters: 'a', 'b', 'c' and 'd'. The concept of conjugates follows a unique pairing mechanism where 'a' pairs with 'b', 'c' pairs with 'd' and vice-versa. As a result, there are only four possible valid conjugate pairs: ('a', 'b'), ('b', 'a'), ('c', 'd'), and ('d', 'c'). The objective is to calculate the total number of valid substrings in a given string s. A string is considered valid if: There exists a permutation of the string such that the original string and its permutation are conjugates of each other. Two strings s and t of the same length say n are considered conjugates if, for every index i (0 <= i < n), the pair formed by the characters at that index (s[i], t[i]) must be a conjugate pair. Given a string s that only contains the characters 'a', 'b', 'c' and 'd'. Return the total number o