목록정렬 (63)
넘치게 채우기
https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 유형 : 정렬 문제 난이도 : Level 1 문제 배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다. 예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면 array의 2번째부터 5번째까지 자르면 [5, 2, 6, 3]입니다. 1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다. ..
https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/description/ Average Salary Excluding the Minimum and Maximum Salary - LeetCodeCan you solve this real interview question? Average Salary Excluding the Minimum and Maximum Salary - You are given an array of unique integers salary where salary[i] is the salary of the ith employee. Return the average salary of em..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/c6wcvR/btsbDESWAxh/kudlEDXOyvMNZGKa0Ri2N0/img.png)
정렬은 데이터들을 주어진 조건에 맞게 순차적으로 나열하는 것이다. 1. 버블 정렬(Bubble Sort) 한 번 순회할 때마다 마지막 하나가 정렬 된다. 거품이 올라오는 것 처럼 보여서 버블 정렬이라고 한다. 두 수를 비교하여, 조건에 맞으면 자리를 바꾼다. O(N^2)의 시간복잡도를 가진다. def bubble_sort(arr): for i in range(len(arr)): for j in range(len(arr)): if arr[i] < arr[j]: arr[i], arr[j] = arr[j], arr[i] 2. 선택 정렬(Selection Sort) 테이블에서 가장 작은 노드를 찾아서 맨 앞으로 위치를 바꾼다. 맨 앞에 놓인 노드 뒤부터 다시 똑같은 과정을 반복한다.(가장 작은 노드를 0번째 인..