2582.js
/** ------------------------------------------------------------------------------
*
* 2582. Pass the Pillow
* Topics: Simulation
* https://leetcode.com/problems/pass-the-pillow/
*
------------------------------------------------------------------------------ */
/**
* @param {number} n
* @param {number} time
* @return {number}
*/
var passThePillow = function (n, time) {
const repeat = Math.floor(time / (n - 1))
const remainder = time % (n - 1)
// 홀수
if (repeat % 2 === 1) {
return n - remainder
// 짝수
} else {
return remainder + 1
}
}
console.log()