정렬 정렬 알고리즘 5문제 풀기 백준 1181 단어 정렬 n = int(input()) words = [] for _ in range(n): words.append(input()) words = list(set(words)) words.sort() words.sort(key = lambda x:len(x)) for x in words: print(x) 백준 3273 두 수의 합 import sys n = int(input()) nums = list(map(int, sys.stdin.readline().rstrip().split())) nums.sort() x = int(input()) cnt = 0 left = 0 right = len(nums) - 1 while left < right: tmp = nu..
정렬 데이터를 특정 기준에 따라 순서대로 나열하는 것 선택 정렬, 삽입 정렬, 퀵 정렬, 계수 정렬이 있다. 선택 정렬 가장 기본적인 정렬 알고리즘으로 가장 작은 것을 왼쪽으로 계속 보내는 (오름차순의 경우) 정렬 방식 arr = [7, 3, 5, 9, 6, 2] for i in range(len(arr)): min_idx = i for j in range(i+1, len(arr)): if arr[min_idx] > array[j]: min_idx = j arr[i], arr[min_idx] = arr[min_idx], arr[i] 시간 복잡도가 $ O(N^2) $ 이기 때문에 원소의 개수가 많으면 효율적이지 못한 알고리즘이다... 삽입 정렬 특정한 데이터를 적절한 위치에 삽입한다는 의미의 삽입 정렬이다..