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

You are given two lists A and
both containing the numbers
1
dotsn in some
order. Your task is to count how many of the numbers
1
dotsn occur earlier on the
list A than on the list
.
In this task,
can be large and an efficient algorithm is required. The time
complexity should be
(
)
.
In a file
twolists.py
,
implement a function count that returns the desired count.
def count
(
a
,
b
)
:
# TODO
if
=
=
"
"
"
:
print
(
count
(
[
2
,
3
,
4
,
1
]
,
[
1
,
2
,
3
,
4
]
)
)
#
3
print
(
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
]
)
#
3
print
(
count
(
[
5
,
4
,
9
,
1
,
8
,
3
,
2
,
6
,
7
]
,
[
6
,
2
,
8
,
4
,
9
,
1
,
5
,
7
,
3
]
)
Explanation: In the first test, the numbers
2
,
3
and
4
occur earlier on the list
than on the list
.

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!