Find frequency of each character with positions in given Array of Strings | Function to print every occurence of every characters in every string ; Iterate over the vector arr [ ] ; Traverse the string arr [ i ] ; Push the pair of { i + 1 , j + 1 } in mp [ arr [ i ] [ j ] ] ; Print the occurences of every character ; Driver Code ; Input ; Function call
def printOccurences ( arr , N ) : NEW_LINE INDENT mp = [ [ ] for i in range ( 26 ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( len ( arr [ i ] ) ) : NEW_LINE INDENT mp [ ord ( arr [ i ] [ j ] ) - ord ( ' a ' ) ] . append ( ( i + 1 , j + 1 ) ) NEW_LINE DEDENT DEDENT for i in range ( 26 ) : NEW_LINE INDENT if len ( mp [ i ] ) == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT print ( " Occurences ▁ of : " , chr ( i + ord ( ' a ' ) ) , " = " , end = " ▁ " ) NEW_LINE for j in mp [ i ] : NEW_LINE INDENT print ( " [ " + str ( j [ 0 ] ) + " ▁ " + str ( j [ 1 ] ) + " ] ▁ " , end = " " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ " geeksforgeeks " , " gfg " ] NEW_LINE N = len ( arr ) NEW_LINE printOccurences ( arr , N ) NEW_LINE DEDENT