본문 바로가기

Python/code problem

[sw expert academy] 1966. 숫자를 정렬하자

https://swexpertacademy.com/main/main.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

  • 56,684 kb메모리
  • 133 ms실행시간
T = int(input())

for t in range(1,T+1):
    N = int(input())
    result = ""
    lst = list(map(int,input().split()))
    lst.sort()
    for i in lst:
        result += str(i) +" "
    print("#{} {}".format(t,result))

 

모범답안에 영감을 받아 join으로도 풀어보면

  • 56,688kb메모리
  • 131ms실행시간
T = int(input())

for t in range(1,T+1):
    N = int(input())
    lst = list(map(int,input().split()))
    lst.sort()
    print("#{} {}".format(t," ".join(map(str,lst))))