Think my solution is O(n) for both parts. I deliberately didn't shortcut part 1 as I figured that I would probably need the full spiral for part 2 (been bitten on previous years of AoC). Glad that today's was a bit more difficult than the 1st couple of days.