Maximum Product of Three in Python and C++ Codility solutions lesson 6

preview_player
Показать описание
This video describes the solution of Codility lesson 6 Maximum Product of Three (MaxProductOfThree) using Python and C++. Good preparation for coding exam or an interview, hope you guys will like it, Good luck. python algorithms interview.

🍓 If you want to follow structured courses with more details and practice exercises check my "About" page for Discount Coupons on my Udemy courses covering: Python basics, Object Oriented Programming and Data Analysis with NumPy and Pandas, ... more courses are on the way drop me a message if you have a particular interesting topic! Good luck!

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

once sort() is invoked(), time complexity becomes N*LogN. When you use three loops, it is N*N*N. I wonder how it can pass performance testing?
It can be done O(n) by finding P1>=P2>=P3, N1<=N2, and max(P1*P2*P3, P1*N1*N2), right?
Also there is case that all numbers are negative.

wenweiweng
Автор

Thank you. Small detail: In Python you can use A[-1], A[-2], A[-3] to get last three elements instead of A[N-1], A[N-2], A[N-3].

Автор

Awesome solution, other resources online way overcomplicate the code!

Godziraaa
Автор

2 hours spent only got %44 with my solution :D Yours is perfect

berkesenturk
Автор

Those negative numbers at it again with their trickery. I rushed my solution the first time and didn't consider what would happen if you have 2 big negative numbers. Tricky tricky tricky.

wonderjaxe
Автор

is the number of element in the array always 6?

datastako
Автор

I achieved a 100 % score with O(n) complexity.

ization
join shbcf.ru