Day 26 of 30

One leetcode problem a day or I pay a follower $500.
No AI. No autocomplete. No copilot

Problem of the day : 2515. Shortest Distance to Target String in a Circular Array

It reads like a shortest path problem. There are no no path to find.

Circular array, start somewhere, step left or right, reach the target. That framing pushes you toward BFS or two crawlers walking in opposite directions. Both correct. Both answering a question nobody asked.

Nothing constrains the walk. No cell is blocked, every step costs the same, and the destinations are known up front. Between any two points on a cycle there are exactly two simple paths, of lengths k and n-k. Every other walk repeats a vertex, and cutting the repeated stretch gives something strictly shorter. So the distance is min(k, n-k). Not searched. Computed.

One detail worth stealing: take k as the plain absolute difference of the two indices, not a modular one. Both are already in range, so no negative modulus and no "+n before %" guard. Circular array code goes wrong at exactly that guard in Go, every time. Here wraparound appears once, as the second argument to a min. Nothing else in the function knows the array is circular.

→ search is for constrained spaces, otherwise it is a formula
→ handle wraparound in one place or it will find you
Day 25 of 30

One leetcode problem a day or I pay a follower $500. No AI. No autocomplete. No copilot

Problem of the day : 657. Robot Return to Origin

Two counters beat four. One counter is wrong. That gap is the entire problem.

A robot L, R. Did it come home?

Write the final position as a sum of unit vectors and the sequence stops mattering. Addition commutes, so "UDLR" and "RRLLUUDD" land on the same square. The input is a multiset wearing a string costume.

Then the axes split. R and L touch only x, U and D touch only y. So it is not one 2D condition, it is two independent 1D balance checks. Four counters compared in pairs is the literal reading. Two signed counters says the same thing with half the state.

Here is where it goes wrong. Having noticed that two beat four, you try one. Check x + y == 0. It passes both examples.

"RD" ends at (1, -1). Two characters and the whole thing falls over.

→ compression is good until it merges things that never interacted
→ every collapse you make needs the counterexample that stops the next one

Independence of the axes means independence of the checks.

Sep 10, 2026 · 10:07 PM UTC

2
0
5
652
RepliesRelevant
Replying to @datachad
@datachad Love the discipline, 26 days in and still going -that’s the impressive part 👍🏻
1
0
1
25
Replying to @LocalAiCherry
@LocalAiCherry Thanks!!!
0
0
1
6
Replying to @datachad
@datachad man you were so close😂😂
1
0
1
22
Replying to @thobbizz
@thobbizz almost missed it haha 😂
0
0
1
12