Leet Code Daily 2024-07-06 - Pass the Pillow
Code
class Solution {
public:
int passThePillow(int n, int time) {
int p = time / (n - 1), q = time % (n - 1);
return p % 2 == 0 ? (1 + q) : (n - q);
}
};class Solution {
public:
int passThePillow(int n, int time) {
int p = time / (n - 1), q = time % (n - 1);
return p % 2 == 0 ? (1 + q) : (n - q);
}
};