FastPrepMaximum Diamond Sum
Problems/Maximum Diamond Sum

Maximum Diamond Sum

Hudson River Trading logoHudson River Trading● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Hudson River Trading new grad online assessment. The report describes a grid and diamond-shaped regions whose sums must be compared. We chose the smallest fixed set of rules: a filled diamond measured by Manhattan radius, a clear list of candidates, a containment rule, and limits on the size. Our version is about 75% the same as the reported question.

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
grid
012012314562789

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
grid
01234011111111111211111311111411111

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
grid
0120-5-1-51-110-12-5-1-5

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.

More Hudson River Trading Online Assessment questions

  • Count Palindrome Addition ChoicesOA · Seen Nov 2026
  • Count Multiples of Three with Two SevensOA · Seen Oct 2026
  • Recursively Expanded Shell Command CountsOA · Seen Oct 2026
  • Rotate Matrix Regions Around the DiagonalsOA · Seen Oct 2026
  • Smallest Most-Lit Street PositionOA · Seen Oct 2026
  • Rearrange String by Alternating EndsOA · Seen Sep 2026
  • Most Items Within Budget from a Start IndexOA · Seen Sep 2026
  • Count Fancy NumbersOA · Seen Sep 2026
  • Count Pieces After Othello MovesOA · Seen Sep 2026
  • Merge Row Trees by Key PathOA · Seen Sep 2026

Similar questions at other companies

  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions
  • Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions
  • Sparse Valid Conv2D From ScratchNVIDIA · OANVIDIA interview questions
  • Apply Matrix OperationsCapital One · OACapital One interview questions
  • Rotate the Box and Drop the StonesZipRecruiter · OAZipRecruiter interview questions
  • 2048 Move SimulatorBenchling · OABenchling interview questions

Interview reports that mention this question

  • HRT SWE Intern and Onsites: 34 Experiences (Part 2 of 2)
  • HRT Python Track Interviews: 64 Experiences (Part 1 of 2)

Hudson River Trading interview experiences

  • Hudson River Trading Quant Video Interview: 1 Experience
  • HRT New Grad Python Track Interviews: 9 Experiences
All Hudson River Trading interview questionsSee Hudson River Trading hiring insights
Saved
class Solution {
    public long maximumDiamondSum(int[][] grid, int[][] diamonds) {
        // Write your code here.
    }
}
Checking account…