줄 서는 방법
210720
from itertools import product
def solution(n, k):
lst = list(map(str, list(range(1, n+1))))
pdt = list(product(*([lst] * n)))
idx = 0
for p in pdt:
if len(set(p)) == n:
if idx == k-1:
return list(map(int, p))
else:
idx += 1
시간초과가 나는 이유는 시간복잡도가 이기 때문이다. 적어도, 아니면 을 바라는 듯 하다.

Last updated
Was this helpful?