Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SUBMIT | RESULTS You are given two lists A and B both containing the numbers 1 dotsn in some order. Your task is to count

SUBMIT | RESULTS
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 =="":
print((count (?bar([2),3,4bar(,1)],[1,2,3,4])
pr(count([1,2,3,4],[1,2,3,4]))#0
print (count ([4,7,3,1,6,2,5],[5,6,1,2,4,3,7])
print (count([5,4,9,1,8,3,2,6,7],[6,2,8,4,9,1,5,7,3]))#5
Explanation: In the first test, the numbers 2,3 and 4 occur earlier on the list A
than on the list B.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions