Find the index having maximum value of lis [ i ] + lds [ i ] + 1
MaxVal = arr [ 0 ] NEW_LINE inx = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if MaxVal < lis [ i ] + lds [ i ] - 1 : NEW_LINE INDENT MaxVal = lis [ i ] + lds [ i ] - 1 NEW_LINE inx = i NEW_LINE DEDENT DEDENT