LeetCode 2582. Pass the Pillow — JavaScript

Gary Huang
Traveling Light Taipei
Jul 6, 2024
A test of seven Copilot+ PCs, representing all four Snapdragon X chips, against similar laptops with Apple Silicon, Intel Core Ultra, and AMD Ryzen processors

https://leetcode.com/problems/pass-the-pillow/description/

你領500元現金了嗎? 點選我的連結成功開樂天帳戶+登入樂天網銀APP,拿500元現金! 樂天帳戶好康在這 : · 使用行動支付5次,享次月活儲年息1.35%存額無上限 · VIP享每月免費跨提/轉共16次 · 提領日幣手續費優惠8次/月 (推薦序號: JGONGL)

var passThePillow = function(n, time) {
const loop = (n-1)*2
const rest = time%loop
return rest>=n ? loop-rest+1 : rest+1
};

1->2->3->2: only 4 moves. 0,1,2,3 and then

1->2->3->2 again

美國洛杉磯 矽谷 軟體公司參訪 美術館 道奇球賽 USA — LA, SJ / FunkyGary / 88rising — California

--

--

Gary Huang
Traveling Light Taipei

自學程式,目前爲 React 前端工程師,兼職線上課程業師,協助程式自學者就業。熱愛旅遊,將近 30 個國家。訂閱我的旅行與街舞 YT :https://www.youtube.com/channel/UCEU-bEDl7R-iGyLVZFae33g