작성
·
242
0
function solution(s, e) {
let min = Number.MAX_SAFE_INTEGER;
const total = e - s;
if (total < 0) return -total;
const recursive = (count, distance) => {
if (count <= Math.floor(total / 5) + 3) {
if ((distance === 0) & (count < min)) min = count;
if (distance > 3) recursive(count + 1, distance - 5);
else if (distance < 0) recursive(count + 1, distance + 1);
else recursive(count + 1, distance - 1);
}
};
recursive(0, total);
return min;
}