Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q5. 볼링공 고르기 질문 드립니다! #177

Open
minha62 opened this issue Mar 12, 2022 · 1 comment
Open

Q5. 볼링공 고르기 질문 드립니다! #177

minha62 opened this issue Mar 12, 2022 · 1 comment

Comments

@minha62
Copy link

minha62 commented Mar 12, 2022

n, m = map(int, input().split())
k = list(map(int, input().split()))
result = 0

for i in range(n):
    for j in range(i, n):
        if k[i] != k[j]:
            result += 1

print(result)

저는 이런 식으로 풀었는데 이렇게 풀어도 괜찮을까요?

책에 나와있는 답안과 많이 다르게 푼 것 같아서 질문 드립니다!

@Yooncoding
Copy link

출력에는 문제가 없으나 시간복잡도 O(n^2)을 가져서 책에 나온 풀이보단 효율이 떨어집니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants