dp [ i ] [ j ] stores the count of subsequence with ' a ' + i and ' a ' + j character
dp = [ [ 0 ] * 26 ] * 26 NEW_LINE freq = numpy . zeros ( 26 ) NEW_LINE dp = numpy . zeros ( [ 26 , 26 ] ) NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT for j in range ( 26 ) : NEW_LINE DEDENT