Distinct Values in Maximum-Sum Square Windows
Updated
Problem statement
Enumerate every size by size submatrix. Find the maximum window sum, collect each distinct value appearing in any tied maximum window, and return their sum.
Function
sumDistinctMaxWindowValues(matrix: int[][], size: int) → longExamples
Example 1
matrix = [[1,2,1],[2,1,2],[1,2,1]]size = 2return = 3All windows tie and the distinct union is {1,2}.
Example 2
matrix = [[1,2],[3,4]]size = 1return = 4The maximum one-cell window contains 4.
Constraints
1 <= rows,columns <= 2001 <= size <= min(rows,columns)
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
- Number of Submatrices That Sum to TargetWhatNot · ONSITE INTERVIEWWhatNot interview questions
- Gaussian Naive Bayes Classifier (Machine Learning OA)Pinterest · OAPinterest interview questions
- Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Find a Symbolic Matrix PatternCapital One · OACapital One interview questions
- Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
- Shortest Digit Prefix for Target MultisetsVisa · OAVisa interview questions
- First Completed Mingo LineEpic · OAEpic interview questions
- Shortest Path Around Rectangular ObstaclesDRW · OADRW interview questions