Leetcode 2582. Pass the Pillow
People stand in a line from 1 to n and pass a pillow one step per second, reversing direction at the ends; given n and time, determine which index holds the pillow after time seconds. Recognize the motion is periodic with period 2*(n-1) and can be solved by mapping time modulo that period to a forward-or-reflected position.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.