Find Frequency of Character Pairs

Write a function that returns the frequency of character pairs (two consecutive characters) in a string.
        
       Input:-ababa
       Input Description: Input a single string. 
       Output: ab:2 ba:2
       Output Description: Output the frequency of character pairs in the format "pair:count". 
       Constraints: 1 <= string length <= 10^6
       Explanation: 

Loading...