Skip to content

Instantly share code, notes, and snippets.

@imsaravana369
Created December 18, 2022 16:59
Show Gist options
  • Save imsaravana369/e1201d313f5d9365e2e8562e4fcfba62 to your computer and use it in GitHub Desktop.
Save imsaravana369/e1201d313f5d9365e2e8562e4fcfba62 to your computer and use it in GitHub Desktop.
Area Under the hill
def solve(self, A):
A.append(0)
n = len(A)
res = 0
x = 1
for i in range(1,n):
res += x*A[i]
x+=1
x = 1
for i in A:
res -= i * x
x +=1
res = abs(res)
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment