multiply the total occurrences of first character before middle character with the total occurrences of third character after middle character
$ total = $ preLeft [ $ i - 1 ] * $ preRight [ $ i + 1 ] ; $ counter += $ total ; } } return $ counter ; }