Skip to content

[백준 10816번] 숫자 카드 2 to improve the time complexity (without using binary search) #3

@xilverh0ya

Description

@xilverh0ya

다음 코드의 개선방법이 궁금합니다.
(이진탐색을 사용하지 않고 시간복잡도를 개선하는 법)

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions