FastPrepDistinct Values on Maximum-Sum Frames
Problems/Distinct Values on Maximum-Sum Frames

Distinct Values on Maximum-Sum Frames

ZipRecruiter logoZipRecruiter● MediumNEW GRADFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two ZipRecruiter OA reports describe fixed-size square frames, maximum border sums, ties across winning frames, removing duplicate values overall, and the reported result 92. The reports leave out limits, a function signature, and reusable image data, so our version supplies those details.

Given an integer matrix and frameSize, consider every contiguous frameSize × frameSize submatrix. Its border contains each cell on its top row, bottom row, left column, or right column exactly once.

Find the maximum border sum. Among every frame tied for that maximum, collect all integer values that occur on a winning border. Return the sum of those distinct values.

Function

sumDistinctWinningBorderValues(matrix: int[][], frameSize: int) → long

Examples

Example 1

matrix = [[1,2,3],[4,5,6],[7,8,9]]frameSize = 2return = 28
matrix
012012314562789

The bottom-right 2-by-2 frame has the unique maximum border sum, and 5+6+8+9=28.

Example 2

matrix = [[1,1,1],[1,0,1],[1,1,1]]frameSize = 2return = 1
matrix
012011111012111

All four frames tie; the union of their border values is {0,1}.

Constraints

  • 1 <= rows, columns <= 200.
  • 1 <= frameSize <= min(rows, columns).
  • Matrix values fit in a 32-bit signed integer; the result fits in a 64-bit signed integer.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Distinct Values on Maximum-Sum FramesCapital One · OACapital One interview questions
  • Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Gaussian Naive Bayes Classifier (Machine Learning OA)Pinterest · OAPinterest interview questions
  • Four-by-Four Boundary GridSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Center of the Largest Perfect X-ShapeTikTok · OATikTok interview questions
  • Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Shortest Path in a Binary MatrixGoogle · OAGoogle interview questions
  • Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
  • Grid Paths with Override PassesIMC Trading · OAIMC Trading interview questions
  • Minimum MovesHarness · OA

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long sumDistinctWinningBorderValues(int[][] matrix, int frameSize) {
      // write your code here
    }
}
Checking account…