다음 코드의 개선방법이 궁금합니다.
(이진탐색을 사용하지 않고 시간복잡도를 개선하는 법)
n = int(input())
n_list = input().split()
m = int(input())
m_list = input().split()
a = []
for i in m_list:
a.append(n_list.count(i))
for i in a:
print(i, end=" ")
in 함수와 count함수가 혼용되면서 O(n ** 2)의 시간복잡도를 가지게 되는데,
같은 플로우로는 해결 방법이 전무할까요?
I was wondering how to improve the time complexity in this code without using binary search.
It's impossible?
다음 코드의 개선방법이 궁금합니다.
(이진탐색을 사용하지 않고 시간복잡도를 개선하는 법)
in 함수와 count함수가 혼용되면서 O(n ** 2)의 시간복잡도를 가지게 되는데,
같은 플로우로는 해결 방법이 전무할까요?
I was wondering how to improve the time complexity in this code without using binary search.
It's impossible?