AbsDistinct Codility In Python And C++ Codility Solutions

preview_player
Показать описание
This video presents the solution of AbsDistinct Codility Lesson 15 in Python and C++. The algorithm is explained and detailed and the code is presented in 2 programming languages. A great preparation for online coding test, online interview and programming job application. Good luck!

🍓 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!
Рекомендации по теме
Комментарии
Автор

Your examples are good but I think they can be more simpler

Initialize an unordered_set;
Loop through the array and in each iteration, insert abs(i) into the unordered_set.

Time complexity
O(n)
Insertions into unordered_set cost O(1) so all that we worry about is the length of the array n and the cost of loop through O(n).

chukwujiobicanon
Автор

Hey! I'm really happy with all your examples! But, I must say sometimes your code in python sometimes need to be more python. I mean there are some internal functions that can help to do it faster, better and cleaner, take a look to this one:

def solution(A):
A = [abs(ele) for ele in A]
A.sort()
return len(set(A))

harozudu
Автор

Thank you for the very clear explanation

drjenniferderm
Автор

Can you develope my project? How to contact you

fazil
visit shbcf.ru