FastPrepMatrix Region Sum
Problems/Matrix Region Sum

Matrix Region Sum

Rippling logoRippling● MediumFULLTIMEOAONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a Rippling OA report and an earlier phone-screen report that give the same matrix-region task and visible examples. Estimated match rate: 95-98% for the judged task. The reports did not provide numeric limits or an exact function signature.

Given an integer matrix matrix and a non-negative region radius r, construct an output matrix of the same size.

For each cell (row, col), sum every input cell (i, j) satisfying:

row - r <= i <= row + r
col - r <= j <= col + r

Only coordinates inside the matrix are included. The center cell is included in its own sum.

Function

matrixRegionSum(matrix: int[][], r: int) → int[][]

Examples

Example 1

matrix = [[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]]r = 1return = [[4,6,6,6,4],[6,9,9,9,6],[6,9,9,9,6],[4,6,6,6,4]]
matrix
01234011111111111211111311111
→
return
01234046664169996269996346664
Moved or new

The top-left cell sees the clipped 2 x 2 region and has sum 4. Interior cells see a full 3 x 3 region and have sum 9.

Example 2

matrix = [[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]]r = 2return = [[9,12,15,12,9],[12,16,20,16,12],[12,16,20,16,12],[9,12,15,12,9]]
matrix
01234011111111111211111311111
→
return
012340912151291121620161221216201612391215129
Moved or new

With radius 2, the center columns include all five input columns while edge cells use clipped regions.

Constraints

  • 1 <= matrix.length, matrix[0].length <= 1000
  • 0 <= r <= 1000
  • All output sums fit in a signed 32-bit integer.

More Rippling Online Assessment questions

  • Most Segments That Sort the ArrayOA · Seen Nov 2026
  • Palindromic Paths to the RootOA · Seen Nov 2026
  • Server InvestmentOA · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • REST API: Highest International StudentsOA · Seen Sep 2026
  • Token ValidationOA · Seen Sep 2026
  • Consistent LogsOA · Seen Sep 2026
  • Costliest ChocolateOA · Seen Sep 2026
  • Server ManagementOA · Seen Sep 2026
  • Cyber Beacon DetectionOA · Seen Aug 2026

Similar questions at other companies

  • Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
  • Shortest Path Around Rectangular ObstaclesDRW · OADRW interview questions
  • Centered K-by-K Submatrix SumsCitadel · ONSITE INTERVIEWCitadel interview questions
  • Inclusive Rectangle Coverage CountsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Sub-matrix SumsIMC Trading · OAIMC Trading interview questions
  • Restaurant Delivery HeatmapDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Alien Defense Turret PlacementBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Largest Sub-GridMathWorks · OAMathWorks interview questions
  • Maximum Trailing Zeros on a Path with at Most One TurnMarshall Wace · OAMarshall Wace interview questions
  • Square-Neighborhood Image BlurZipRecruiter · OAZipRecruiter interview questions

Interview reports that mention this question

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)

Rippling interview experiences

  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
  • Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int[][] matrixRegionSum(int[][] matrix, int r) {
      // write your code here
    }

}
Checking account…