2582.Pillow
topic:
Thought:
math题,Find a rule,npersonal,interval=n-1,The number of cycles in the crowd= ,The number of cycles is2The number of times from scratch,Otherwise, the number of forwards from the back。
Code:
class Solution:
def passThePillow(self, n: int, time: int) -> int:
if n > time:
return time + 1
if time // (n-1) % 2 == 0:
return time % (n-1) + 1
else:
return n - time % (n-1)贡献者
这篇文章有帮助吗?
最近更新
Involution Hell© 2026 byCommunityunderCC BY-NC-SA 4.0
2562.Find the series of the array
LeetCode 2562. 找出数组的串联值 题解 — 使用双指针技巧从数组两端逐步取出数字并拼接为串联值,关键点在于正确处理正负索引的转换关系,避免越界错误。适合正在刷 LeetCode 双指针题型、需要巩固数组索引边界处理的求职者和算法学习者。
1004.Maximum continuity1Number III Maximum continuity1Number III
LeetCode 1004. 最大连续1的个数 III 题解 — 滑动窗口与双指针解法,核心技巧在于维护窗口内最多翻转 K 个 0,通过动态调整左右指针实现最长连续 1 子数组。适合准备算法面试、刷题进阶的 CS 求职者与 AI 学习者。