Reported September 2026
Capital Oneprefix sum

Maximum Rhombic Area Sum

Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Capital One OA. Under 2s to a working solution.
Founder's read

A 100 by 100 grid and a radius that can reach 50 sounds harmless until you do the math. The Capital One OA reported in September 2026 asks for the maximum rhombic area sum, and the naive approach recounts up to about 5000 cells for every one of 10,000 centers. That's the first thing the constraints are warning you about. The real question is how to get each diamond sum without rescanning it. If you freeze when the diagonal bookkeeping gets ugly, StealthCoder is the invisible safety net running during the live OA. Here's the pattern and the trap.

The problem

You are given a rectangular integer matrix matrix and a positive integer r.
A rhombic area of size r centered at (centerRow, centerCol) contains every cell (row, col) whose Manhattan distance from the center is less than r:
|row - centerRow| + |col - centerCol| < r
Equivalently, the center has radius number 1, its orthogonally adjacent cells have radius number 2, and all cells with radius numbers from 1 through r belong to the area.
A center is valid only when its entire rhombic area lies inside the matrix. Return the maximum sum of the matrix values in any valid rhombic area of size r.

Function
maximumRhombicSum(matrix: int[][], r: int) → int

Examples
Example 1
matrix = [[1,2,3],[4,5,6],[7,8,9]]
r = 2
return = 25
The only valid center is the middle cell. Its rhombic area contains 5, 2, 4, 6, and 8, whose sum is 25.
Example 2
matrix = [[-5,2],[3,1]]
r = 1
return = 3
With r = 1, each rhombic area contains only its center. The largest cell value is 3.
Example 3
matrix = [[1,1,1,1],[1,5,1,1],[1,1,4,1],[1,1,1,1]]
r = 2
return = 12
A rhombus centered at (1, 2) contains values 1, 1, 5, 1, and 4, for a sum of 12. The center (2, 1) also gives 12, and no valid center gives a larger sum.

Constraints
1 <= matrix.length <= 100
1 <= matrix[i].length <= 100
Every row has the same length.
-10^4 <= matrix[i][j] <= 10^4
1 <= r <= min((matrix.length + 1) / 2, (matrix[0].length + 1) / 2)

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is prefix sums, but not the usual row and column kind. A diamond is a union of rows, and each row's slice has a known width: r at the center row, shrinking by one per step away. So build a prefix sum per row. Then for each valid center, loop over 2r-1 rows, compute the slice width from the row offset, and add one prefix difference per row. That costs about 100 * 100 * 100 = 10^6 operations, which is fine. Valid centers only run from r-1 to size-r in each dimension, so no bounds checks are needed inside the loop. The pitfall is off-by-one on the width. Radius number r means distance less than r, so the half-width at offset d is r-1-|d|. Negative values mean you can't initialize the max to 0. Use negative infinity. If the width math slips mid-assessment, StealthCoder can hand you the working version.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Maximum Rhombic Area Sum cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Capital One's OA.

Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Rhombic Area Sum FAQ

What's the trick for Maximum Rhombic Area Sum?+

Build a prefix sum for every row. A diamond is just a stack of horizontal slices whose widths grow then shrink. For each center, sum one prefix difference per row. You never touch individual cells, so the work stays near 10^6 operations on a 100 by 100 grid.

Why does brute force fail on the Capital One version?+

It may not strictly fail, but it's wasteful. With a 100 by 100 matrix and r up to 50, each diamond holds roughly 5000 cells and there are thousands of centers. That's tens of millions of reads. Per-row prefix sums cut each diamond to about 2r-1 lookups.

How do I find which centers are valid?+

The whole diamond must fit, so the center row must be between r-1 and rows-r, and the center column between r-1 and cols-r. Loop only over that range. The constraint on r guarantees at least one valid center exists, so you always have an answer.

What's the most common bug here?+

Two things. First, the half-width off-by-one: at row offset d, you include columns from center minus (r-1-|d|) to center plus (r-1-|d|). Second, starting the max at 0 when all values can be negative. Start with negative infinity or the first computed sum.

How do I prepare for this in 48 hours?+

Write the per-row prefix sum version once from scratch and test it on the three examples, especially the r=1 negative case. Then practice 2D prefix sum problems so the indexing feels automatic. This is a geometry-flavored prefix sum question, not a hard algorithm.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Capital One.

OA at Capital One?
Invisible during screen share
Get it