Question: You are given two lists A and B both containing the numbers 1 dotsn in some order. Your task is to count how many of

You are given two lists A and B both containing the numbers 1dotsn in some
order. Your task is to count how many of the numbers 1dotsn occur earlier on the
list A than on the list B.
In this task, n can be large and an efficient algorithm is required. The time
complexity should be O(n).
In a file
twolists.py, implement a function count that returns the desired count.
def count(a, b):
# TODO
if __name__=="__main__":
a = list(range(1,10**5+1))
b = list(range(1,10**5+1))
print(count(a,b))
Explanation: In the first test, the numbers 2,3 and 4 occur earlier on the list A
than on the list B.
 You are given two lists A and B both containing the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!