Skip to content

Instantly share code, notes, and snippets.

@thekhairul
Last active April 5, 2022 04:59
Show Gist options
  • Save thekhairul/a73f051999c3fccb39f9b47290f2e18e to your computer and use it in GitHub Desktop.
Save thekhairul/a73f051999c3fccb39f9b47290f2e18e to your computer and use it in GitHub Desktop.
Interviewbit - Return the highest product possible by multiplying 3 numbers from the array - python
def maxp3(self, A):
A.sort()
maxp3 = 1
max3 = A[-3:]
for x in max3:
maxp3 *= x
edge = A[0] * A[1] * A[-1]
return max(edge, maxp3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment