일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 자바스크립트
- 가천대
- socket
- 알고리즘
- 크롤링
- Algorithm
- dp
- 프로그래머스
- HTTP
- 쉬운 문제
- type challenge
- Crawling
- 레벨 1
- 소켓
- 프로그래머스 레벨 2
- 문자열
- 수학
- HTTP 완벽 가이드
- 백준
- 타입 챌린지
- Node.js
- 그래프
- TCP
- ip
- Nestjs
- BFS
- typescript
- dfs
- 타입스크립트
- javascript
- Today
- Total
목록정렬 (3)
kakasoo

첫번째부터 두번째까지는 버블 정렬을 시도한 것이다. 그런데 시간 초과가 나왔다. 아니, 문제가 버블 정렬인데 버블 정렬 했다고 시간 초과라니, 문제가 잘못된 것 아닌가 해서 봤더니, A에 들어있는 수가 100만까지 나올 수 있다고 한다. 버블 정렬은 O(n^2) 이었으니까 100만의 제곱이면... 아하, 이건 해결할 수 없는 방식이었다. 이 문제는 버블 정렬을 시키진 않을 거면서 버블 정렬을 하면 몇 번이나 걸리는지를 묻는 문제였다. 그래서 방식을 바꾼 게, 버블 정렬이 어떤 조건에서 발생하는지를 보는 것이었다. 버블 정렬을 하면 각 자리 수는 좌측으로 한 칸씩 이동하게 된다. 예를 들어 예제처럼, 10, 1, 5, 2, 3의 숫자가 있다고 해보자. 1, 2, 3, 5, 10으로 정렬되어야 한다. 그러면..

// 백준 2752번 세수 정렬을 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { main(line); rl.close(); }).on("close", () => process.exit()); /** * * @param {string} line */ const main = (line) => { const numbers = line .split(" ") .map(Number) .sort((a, b) => a - b) .join(" "); console.log(numbers)..

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include #include using namespace std; int a[100]; int b[100]; int main(void) { int n; cin >> n; for (int i = 0; i > a[i]; } for (int i = 0; i > b[i]; } sort(a, a + n); sort(b, b + n); int sum = 0; for (int i = 0; i