python-algorithm

codeforces 978A - Remove Duplicates

무적김두칠 2022. 5. 26. 09:48

1
2
3
4
5
6
7
8
9
10
def sol(n,nums):
    ans=[]
    for i in range(1,n+1):
        if nums[-i] not in ans:
            ans.append(nums[-i])
    print(len(ans))
    print(*ans[::-1])
n=int(input())
nums=list(map(int,input().split()))
sol(n,nums)
cs
반응형