We iterate from a nested-loop pair check to a single-pass scan that only remembers the most recent 1 and 2. The "last-s…
We iterate from a full-string scan to a half-string walk by noticing the mirror-index symmetry between `s[i]` and `s[n …
We iterate from a brute-force pair check through a divisor sieve, then drop the constant factor with numpy. Inverting t…
We work through an if/elif ladder, then tighten the range checks using Python's chained-comparison syntax. The `a <= x …
We sum each row of the adjacency matrix to read off every vertex's degree in one pass. The row-sum-equals-degree identi…
We iterate from a brute-force scan to a two-pass sweep that precomputes a right-min array and walks a running left-max.…
We cast the number to a string to check for the digit while guarding against a leading match. The "cast-to-string for d…
We iterate from a brute-force scan to a two-pass sweep that walks a running max from each end. The "two-pass running ma…