Notice
Recent Posts
Recent Comments
Link
모르면 배우면 된다
알고리즘문제 본문
백준 2525 번 오븐시계
const ovenTime = (hh, mm, time) => {
//time을 60으로 나눈 몫quotient과 나머지remainder를 구하기
//mm에다가 remainder 더하기.
//1) mm+remainder > 60일 때, remainder = mm+remainder -60 하고, quotient에 +1
//2) mm+remainder < 60일 때는 그냥 두기
//hh+quotient하기
// hh >=24면, hh = 0
//input 값 유효성검사
if(time<0 && time>=1000){
return 0;
}
if(!(0<=hh && 24>hh)){
return 0 ;
}
if(!(0<=mm && 59>mm)){
return ;
}
let HH = hh+ Math.floor(time/60);
let MM = mm + time%60;
console.log(HH , MM)
if(MM>=60){
MM = MM-60;
HH = HH+1;
}
return HH >= 24 ? `0 ${MM}` : `${HH} ${MM}`
}
ovenTime(70, 48, 25);'알고리즘' 카테고리의 다른 글
| 알고리즘- 재귀함수 정리 (0) | 2022.06.02 |
|---|---|
| 알고리즘 - 배열을 비교할 때 사용하는 알고리즘 (0) | 2022.05.31 |
| 알고리즘-배열과 객체의 시간 (0) | 2022.05.30 |
| 알고리즘- 빅오, 시간복잡도, 공간복잡도 (0) | 2022.05.29 |
| StringBuilder의 활용 (0) | 2021.11.17 |