Sum of array elements that is first continuously increasing then decreasing | Efficient python method to find sum of the elements of array that is halfway increasing and then halfway decreassing ; Driver code
def arraySum ( arr , n ) : NEW_LINE INDENT x = ( n + 1 ) / 2 NEW_LINE return ( arr [ 0 ] - 1 ) * n + x * x NEW_LINE DEDENT arr = [ 10 , 11 , 12 , 13 , 12 , 11 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE print ( arraySum ( arr , n ) ) NEW_LINE