-
Notifications
You must be signed in to change notification settings - Fork 97
2022年04月18日(월) jaewon1676 7문제의 풀이 추가 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ab5aeca
Add 220418 최댓값과-최솟값 1개의 풀이 추가
jaewon1676 14860ae
Create 220418 n^2-배열-자르기 파일 생성 후 1개의 풀이 추가
jaewon1676 531ffdb
Create 220418 단속카메라 파일 생성 후 1개의 풀이 추가
jaewon1676 5b64e15
Add 220418 카펫 1개의 풀이 추가
jaewon1676 22af6f2
Add 220418 소수-만들기 1개의 풀이 추가
jaewon1676 b598c1e
Add 220418 체육복 1개의 풀이 추가
jaewon1676 1725b3d
Add 220418 JadenCase-문자열-만들기.js 1개의 풀이 추가
jaewon1676 8ee3128
Automatic Update README.md
invalid-email-address File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 45 additions & 43 deletions
README.md
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
level-2/n^2-배열-자르기.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //https://github.com/codeisneverodd/programmers-coding-test | ||
| //완벽한 정답이 아닙니다. | ||
| //정답 1 - jaewon1676 | ||
| function solution (n, left, right) { | ||
| const answer = []; | ||
|
|
||
| for (let i=left; i <= right; i++) { // left부터 right까지를 구한다. | ||
| let row = parseInt(i/n); // 행(row)을 구한다. | ||
| let column = i%n; // 열(column)을 구한다. | ||
| answer.push(Math.max(row, column) + 1) // 행과 열중 큰 값을 푸시한다. | ||
| } | ||
| return answer | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
level-3/단속카메라.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| //https://github.com/codeisneverodd/programmers-coding-test | ||
| //완벽한 정답이 아닙니다. | ||
| //정답 1 - jaewon1676 | ||
| function solution(routes) { | ||
| let cctv = 1; // cctv의 개수는 최소 1개 | ||
| routes.sort((a, b) => a[0] - b[0]); // 고속도로 진입 시점을 기준으로 오름차순 정렬 | ||
| // [ [ -20, -15 ], [ -18, -13 ], [ -14, -5 ], [ -5, -3 ] ] | ||
| let out = routes[0][1]; // -15 | ||
| // 나간 시점(out)은 첫 차량의 나간시점으로 초기화 | ||
|
|
||
| for(let i = 1; i < routes.length; i++) { | ||
| // 나간 시점(out)보다 현재 차량의 진입이 느리다면 카메라 추가 설치 | ||
| if(out < routes[i][0]) { | ||
| cctv++; | ||
| out = routes[i][1]; // out 시점 업데이트 | ||
| } | ||
|
|
||
| // 나간 시점(out)이 현재 차량의 진출시점보다 큰 경우 | ||
| if(out > routes[i][1]) { | ||
| out = routes[i][1]; // out 시점 업데이트 | ||
| } | ||
| } | ||
|
|
||
| return cctv; | ||
| } | ||
| // 그리디 | ||
|
|
||
| // 우리는 카메라를 최소로 설치 해야합니다. 그러기 위해서는 고속도로 진입 시점을 기준으로 오름차순 정렬을(빨리 진입한 순) 합니다. | ||
| // 이렇게 되면 배열에 있는 모든 고속도로 진입 시점은 배열의 첫번째 고속도로 진입 시점보다 더 뒤에 있습니다. 그러므로 우리는 | ||
| // 나간시점만 검사 해주면 됩니다. | ||
|
|
||
| // 먼저 첫번째 routes의 고속도로를 빠져나간 시점을 out 변수에 담아줍니다. | ||
| // 이 out 변수를 두번째 routes의 고속도로를 빠져나간 시점과 비교하여 out 변수보다 route[i][1]가 크면 ( 나간 시간이 느리면) | ||
| // cctv를 하나 늘려줍니다. , out 변수를 갱신 하며 세번째, 네번째도 계속 비교해줍니다. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.