Exploring all paths , and storing maximum value in DP table to avoid further repetitive recursive calls
dp [ l ] [ r ] [ num ] = ( current_sum + max ( MaximumScoreDP ( l + 1 , r , prefix_sum , num + 1 ) , MaximumScoreDP ( l , r - 1 , prefix_sum , num + 1 ) ) ) NEW_LINE return dp [ l ] [ r ] [ num ] NEW_LINE