TheRealSamuel/LeetCodeProblem
0572
1{2 "id": 2645,3 "name": "pass_the_pillow",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/pass-the-pillow/",6 "date": "2023-02-26 00:00:00",7 "task_description": "There are `n` people standing in a line labeled from `1` to `n`. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow in the opposite direction. For example, once the pillow reaches the `nth` person they pass it to the `n - 1th` person, then to the `n - 2th` person and so on. Given the two positive integers `n` and `time`, return _the index of the person holding the pillow after _`time`_ seconds_. **Example 1:** ``` **Input:** n = 4, time = 5 **Output:** 2 **Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3 -> 4 -> 3 -> 2. After five seconds, the 2nd person is holding the pillow. ``` **Example 2:** ``` **Input:** n = 3, time = 2 **Output:** 3 **Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3. After two seconds, the 3rd person is holding the pillow. ``` **Constraints:** `2 <= n <= 1000` `1 <= time <= 1000` **Note:** This question is the same as 3178: Find the Child Who Has the Ball After K Seconds.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "n = 4, time = 5",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "n = 3, time = 2",17 "output": "3 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 724,24 59825 ],26 "output": 59927 },28 {29 "input": [30 977,31 31932 ],33 "output": 32034 },35 {36 "input": [37 638,38 48139 ],40 "output": 48241 },42 {43 "input": [44 436,45 18946 ],47 "output": 19048 },49 {50 "input": [51 31,52 20253 ],54 "output": 2355 },56 {57 "input": [58 603,59 87260 ],61 "output": 33362 },63 {64 "input": [65 952,66 3967 ],68 "output": 4069 },70 {71 "input": [72 440,73 94474 ],75 "output": 6776 },77 {78 "input": [79 668,80 58781 ],82 "output": 58883 },84 {85 "input": [86 455,87 33288 ],89 "output": 33390 }91 ],92 "haskell_template": "passThePillow :: Int -> Int -> Int\npassThePillow n time ",93 "ocaml_template": "let passThePillow (n: int) (time: int) : int = ",94 "scala_template": "def passThePillow(n: Int,time: Int): Int = { \n \n}",95 "java_template": "class Solution {\n public int passThePillow(int n, int time) {\n \n }\n}",96 "python_template": "class Solution(object):\n def passThePillow(self, n, time):\n \"\"\"\n :type n: int\n :type time: int\n :rtype: int\n \"\"\"\n "97}