Find Jobs
Hire Freelancers

optimize python algorithm function - find out what elements are added and deleted in second list

$80-240 HKD

Completed
Posted about 5 years ago

$80-240 HKD

Paid on delivery
basically, I need to compare two lists. I need to know what elements are added and deleted. Here is my code but it's running slow. I would like to have "high speed" version function instead of this. import itertools def compareQueues2(prev:list, curr:list): common_max_length = min(len(prev), len(curr)) m1=0 for pi in prev: for ci in curr: if pi == ci: m1+=1 break notfound = True prev_same = [] curr_same = [] common_max_length=min(common_max_length, m1) for n in range(common_max_length, 0, -1): # print(n) if notfound: for p_it in [login to view URL](range(len(prev)), n): # print (p_it) if notfound: for c_it in [login to view URL](range(len(curr)), n): s = sum([prev[p_it[i]] == curr[c_it[i]] for i in range(n)]) if s == n: #print("{} matches {}".format(p_it, c_it)) prev_same = p_it curr_same = c_it notfound = False break deleted = [i for i in range(len(prev)) if i not in prev_same] added = [i for i in range(len(curr)) if i not in curr_same] return prev_same, curr_same, deleted, added --------------------- compareQueues2(['ab', 'will del', 'gh', 'cc'], ['ab', 'gh','added', 'cc']) sample result: ((0, 2, 3), (0, 1, 3), [1], [2])
Project ID: 18624003

About the project

3 proposals
Remote project
Active 5 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
I have experience with algorithms and data structures using python. We shall discuss the rest of the details on chat.
$95 HKD in 1 day
4.9 (4 reviews)
2.1
2.1
3 freelancers are bidding on average $178 HKD for this job
User Avatar
Hi! I need to see input data to understand ways, how to optimize algorithm. But there are several approaches to do it. Let's discuss in chat!
$200 HKD in 2 days
4.9 (12 reviews)
3.7
3.7
User Avatar
I'm an experienced Python developer and some of my skills are analyzing and optimizing algorithms. For that reason I think I'm the best candidate for this work.
$240 HKD in 0 day
3.1 (4 reviews)
3.3
3.3

About the client

Flag of HONG KONG
Hong kong, Hong Kong
5.0
5
Payment method verified
Member since Apr 12, 2018

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.