본문 바로가기

알고리즘

[algorithm] Edge of the Ocean(adjacentElementsProduct/shapeArea)

4. adjacentElementsProduct

 

def adjacentElementsProduct(inputArray):

        return max([inputArray[i]*inputArray[i+1]for i in range(len(inputArray)-1)])

5. shapeArea

def shapeArea(n):
    sum = 1
    for i in range(n):
        sum += 4*i
    return sum