human
Count of maximum occurring subsequence using only those characters whose indices are in GP | Function to count maximum occurring subsequence using only those characters whose indexes are in GP.
Initialize 1 - D array and 2 - D dp array to 0.
Iterate till the length of the given string.
Update ans for 1 - length subsequence.
Update ans for 2 - length subsequence.
Return the answer.
Given string s.
Function call"
Solution in Python:
assistant
#Here is code to count of maximum occurring subsequence using only those characters whose indices are in GP and the other steps required.
 def findMaxTimes ( S ) :
	arr = [ 0 ] * 26
	dp = [ [ 0 for x in range ( 26 ) ] for y in range ( 26 ) ]
	for i in range ( len ( S ) ) :
		now = ord ( S [ i ] ) - ord ( ' a ' )
		for j in range ( 26 ) :
			dp [ j ] [ now ] += arr [ j ]
		arr [ now ] += 1
	ans = 0
	for i in range ( 26 ) :
		ans = max ( ans , arr [ i ] )
	for i in range ( 26 ) :
		for j in range ( 26 ) :
			ans = max ( ans , dp [ i ] [ j ] )
	return ans
S = " ddee "
print ( findMaxTimes ( S ) )