Here's what matters: when moving clockwise on a ring, you can only go forward. If you're at house and need to reach house , you can't go backward. You must continue clockwise through houses .
I'll show you the formula. If you're at position current and need to reach target: if target >= current, the distance is target - current. Otherwise, you wrap around: n - current + target.
This pattern handles circular structures in code. You'll see it in problems about clocks, calendars, and any scenario where numbers wrap around after reaching a maximum.