What it is
A circular array treats index n-1 as adjacent to index 0, so any pattern that normally reasons about "the next element" or "the ends of the array" has to account for wraparound. Interviewers under this label aren't testing a new algorithm — they're testing whether you can take a technique you already know (DP over a line, a monotonic stack, a running max) and correctly adapt it to a circle, usually by splitting the circular case into a small number of linear subcases (break the circle at one point, or solve it with and without wraparound and compare) rather than inventing a fundamentally new approach.
When it applies
- The problem explicitly says positions or elements wrap around from the last index to the first (a circular street of houses, a circular buffer of temperatures, a round table).
- The underlying decision — take-or-skip, next-greater, maximum-subarray-sum — is one you'd normally solve with a straight left-to-right pass, and the only new wrinkle is that the ends now touch.
- If "circular" only means the values repeat or cycle in some other sense (like modular arithmetic on values, not adjacency of positions), this pattern doesn't apply — check specifically whether index 0 and index n-1 are adjacent in the problem's own terms before reaching for a wraparound trick.
Tells in the problem
- "Arranged in a circle," "the element after the last one is the first one again," or an explicit note that position 0 and position n-1 are neighbors.
- A non-adjacency or no-repeat-index constraint stated alongside circular wraparound (you can wrap, but can't use the same index twice).
- A request to reuse a familiar linear recurrence (house robber's adjacency rule, Kadane's maximum subarray) but on a ring instead of a line.
- "May wrap around the end" phrased as an explicit possibility for a subarray or subsequence, rather than the default case.
The classic mistake
Patching the original linear algorithm in place to "handle wraparound" with extra conditionals instead of recognizing that most circular problems decompose cleanly into two or three independent linear subproblems whose results you just compare or combine — for example, running the same linear DP once excluding the first element and once excluding the last, and taking the max of the two, rather than trying to make one pass that is aware of the circle the whole time. Tangled in-place patches are where subtle bugs at the exact wraparound boundary hide. Catch it by first asking "can I turn this circle into two or three straight lines and reuse my linear solution unchanged on each," before reaching for anything more clever.
Questions to start with
- House Robber II — the cleanest decomposition: solve the linear house-robber twice, once excluding the first house and once excluding the last, and take the better result.
- Maximum Sum Circular Subarray — a trickier split: the best answer either doesn't wrap (plain Kadane) or wraps (total sum minus the minimum subarray), and you need both cases plus an all-negative edge case.
- Next Greater Element II — combines the circular-array idea with a monotonic stack, simulating wraparound by iterating over the array twice instead of splitting into cases.