From bd4d2f7f46ec1dc0aa909afa499a27c5134167bc Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Sat, 6 Jul 2024 19:27:02 +0900 Subject: [PATCH] https://leetcode.com/problems/pass-the-pillow --- easy/pass_the_pillow.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 easy/pass_the_pillow.py diff --git a/easy/pass_the_pillow.py b/easy/pass_the_pillow.py new file mode 100644 index 0000000..e520036 --- /dev/null +++ b/easy/pass_the_pillow.py @@ -0,0 +1,6 @@ +# https://leetcode.com/problems/pass-the-pillow + +class Solution: + def passThePillow(self, n: int, time: int) -> int: + pos = time % (2 * (n - 1)) + return n - abs(n - 1 - pos)