Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- PCCP
- 프로그래머스
- InfluxDB
- 파이썬
- algorhtim
- algorighm
- modbus
- javascript
- pnpm
- Algorithm
- 스택/큐
- Jest
- 완전탐색
- Stack
- 슬라이딩 윈도우
- queue
- Two Pointer
- Vite
- Server monitoring
- frontend
- configfile
- python
- 알고리즘
- React
- monorepo
- 코딩테스트 연습
- telegraf
- pymodbus
- 점화식
- typescript
Archives
- Today
- Total
DM Log
[연습문제] 인사고과 - Python/JavaScript 본문
문제 링크 - https://school.programmers.co.kr/learn/courses/30/lessons/152995
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
[문제 간단 요약]
1. scores의 0번에 위치한 완호의 근무 태도와 동료 평가 점수의 합의 석차를 구하는 문제
2. 근무 태도와 동료 평가 점수 기록이 둘다낮은 경우 -1 출력
[문제 해결 방안]
1. 제한 사항의 scores의 길이 가 10,000 이므로 완전 탐색을 통해 구할 시 시간 초과 발생
2. 근무 태도 점수를 내림차순 / 동료 평가 점수를 오름차순 하여 동료 평가 점수를 갱신하며 문제 해결
[문제 해결 코드 - Python]
def solution(scores):
answer = 1
wanho_at,wanho_ex = scores[0]
scores.sort(key=lambda x:(-x[0],x[1]))
pass_num = 0
for score in scores:
check_at, check_ex = score
if wanho_at < check_at and wanho_ex < check_ex:
return -1
if pass_num <= check_ex:
if wanho_at+wanho_ex < check_at+check_ex:
answer+=1
pass_num = check_ex
return answer
[문제 해결 코드 - JavaScript]
function solution(scores) {
let answer = 1;
let [wanhoAt, wanhoEx] = scores[0];
scores.sort((a, b) => b[0] - a[0] || a[1] - b[1]);
let passNum = 0;
for (let i = 0; i < scores.length; i++) {
let [checkAt, checkEx] = scores[i];
if (wanhoAt < checkAt && wanhoEx < checkEx) {
return -1;
}
if (passNum <= checkEx) {
if (wanhoAt + wanhoEx < checkAt + checkEx) {
answer++;
}
passNum = checkEx;
}
}
return answer;
}
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[연습문제] 최솟값 만들기 - Python/JavaScript (1) | 2025.02.02 |
---|---|
[연습문제] 최댓값과 최솟값 - Python/JavaScript (1) | 2025.02.01 |
[코딩테스트 연습] 혼자서 하는 틱택토 - Python (1) | 2025.01.12 |
[2023 KAKAO BLIND RECRUITMENT] 이모티콘 할인 행사 - Python (3) | 2025.01.11 |
[PCCP 기출문제] 2번 / 석유 시추 - Python/JavaScript (0) | 2025.01.08 |