Reported October 2026
Hudson River Tradingmatrix

Maximum Diamond Sum

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

Get StealthCoderRuns invisibly during the live Hudson River Trading OA. Under 2s to a working solution.
Founder's read

A radius-one diamond in a 3x3 grid sums to 25, but the center cell alone can beat the bigger shape when the neighbors are negative. That's the Hudson River Trading Maximum Diamond Sum question reported in October 2026. You get a grid and up to 10000 listed diamonds, each [row, column, radius], and you return the best sum. It looks like geometry, but it's a counting and summing problem with a friendly constraint. If the Manhattan-distance setup makes you freeze, StealthCoder is the safety net that runs invisibly during the live OA and hands you a working solution.

The problem

You are given an integer matrix grid and a list diamonds. Each diamond is [row, column, radius] and contains every cell whose Manhattan distance from its center is at most radius.
Only diamonds fully contained in the matrix are listed. Return the maximum sum of the cells in any listed diamond.

Function
maximumDiamondSum(grid: int[][], diamonds: int[][]) → long

Examples
Example 1
grid = [[1,2,3],[4,5,6],[7,8,9]]
diamonds = [[1,1,1],[1,1,0]]
return = 25
The radius-one diamond contains 2, 4, 5, 6, and 8, whose sum is 25.
Example 2
grid = [[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]]
diamonds = [[2,2,2],[1,1,1]]
return = 13
The radius-two diamond has thirteen cells, more than the five-cell alternative.
Example 3
grid = [[-5,-1,-5],[-1,10,-1],[-5,-1,-5]]
diamonds = [[1,1,1],[1,1,0]]
return = 10
The center-only diamond is better because the surrounding values reduce the larger diamond's sum.

Constraints
1 <= grid.length, grid[0].length <= 200.
The matrix is rectangular and -10^6 <= grid[r][c] <= 10^6.
1 <= diamonds.length <= 10000.
Every diamond has nonnegative radius and is fully contained in the matrix.
The total number of cells across all listed diamonds is at most 10^6.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Read the last constraint twice: total cells across all listed diamonds is at most 10^6. That means brute force is allowed. For each diamond, loop dr from -radius to radius, then loop dc from -(radius-|dr|) to (radius-|dr|), and add grid[row+dr][col+dc]. Track the max. No prefix sums needed, though a per-row prefix sum makes each diamond O(radius) if you want a hedge. The pitfalls are real. Initialize the max to negative infinity, not zero, because all-negative grids exist and example 3 shows small diamonds winning. Use a 64-bit accumulator since the return type is long. Don't assume the biggest radius wins. If you blank on the loop bounds mid-assessment, StealthCoder can supply the clean version while you keep your head straight.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Maximum Diamond 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Hudson River Trading's OA.

Hudson River Trading reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Diamond Sum FAQ

What's the trick in Maximum Diamond Sum?+

The trick is noticing the constraint that total cells across all diamonds is at most 10^6. That makes direct enumeration fast enough. For each diamond, walk the rows from -radius to radius and the columns within the remaining width, summing as you go.

Why not just pick the largest radius?+

Because negative cells drag the sum down. Example 3 shows it: the center cell is 10, but the radius-one diamond adds -1 and -1 values around it and lands lower. You have to compute every listed diamond and compare.

Do I need prefix sums here?+

No. The cell budget of 10^6 means brute force passes. Per-row prefix sums are an optional speedup that cut each diamond to O(radius) work. Only add them if you're confident, since the simple loop has fewer ways to break.

What bugs sink this problem?+

Starting the max at 0 is the big one, since every diamond could be negative. Next is overflow, so use a 64-bit sum. Last is off-by-one in column bounds. The width at row offset dr is radius minus the absolute value of dr.

How do I prepare for this in 48 hours?+

Write the nested loop on paper with example 1 and verify you get 25. Then test an all-negative grid and a radius-zero diamond. Spend remaining time on general matrix traversal and 2D prefix sums, since Hudson River Trading style questions often hide a simple loop behind a scary setup.

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

OA at Hudson River Trading?
Invisible during screen share
Get it