Untitled
unknown
plain_text
9 months ago
359 B
2
Indexable
class Solution { public: int passThePillow(int n, int time) { int direction = time/(n-1); if(direction & 1) { return n-(time%(n-1)); } return (time % (n-1)) + 1; } }; //time/(n-1) is odd then opposite, answer = (n-(time%(n-1))) //time/(n-1) is odd then normal, answer = (time%(n-1)) + 1
Editor is loading...
Leave a Comment