Nice approach! How would you support a finite sliding window as well?
BTW, i think you got a bug when you check the negative curr, i think it should be: if (curr < 0) { curr = num + (curr % num); }
curr
if (curr < 0) { curr = num + (curr % num); }
Nice approach!
How would you support a finite sliding window as well?
BTW, i think you got a bug when you check the negative
curr
, i think it should be:if (curr < 0) { curr = num + (curr % num); }