Max Product of Three Codility Test | Solve with Me | Full Tutorial Explanation using Python

preview_player
Показать описание
Ever use the "heapq" module? Ride along with me for this test and see how we do! Can we really get 100% in performance?

_________________________________________

_________________________________________

"We proclaim Him [Messiah Yahshua], admonishing and teaching everyone with all wisdom, so that we may present everyone perfect in Him."
—Colossians 1:28

#codilitytest #maxproductofthree #python
Рекомендации по теме
Комментарии
Автор

My solution is basically the same as your last one. Here was my approach:

"""
Given we do not need to know the indexes of the triplet and only the best possible
value. If we sort the array. The maximum value will be a triplet made of either:

* 3 most positive values in the sorted array.
* 2 most negative values and the most positive value from the sorted array.
"""

A.sort()

a = A[0] * A[1] * A[-1]
b = functools.reduce(lambda x, y: x * y, A[-3:])

return a if a > b else b

franciscokloganb
Автор

You are really excelling at these concepts! Great work! See you in the next video...

FREESPUR
Автор

Thank you for the video! It helped me a lot =)

PomboKad
Автор

Hello Joy! Good to discover your fascinating content today. I wish you and your channel all the best in 2020.

SamuelDaram
visit shbcf.ru