FastPrepFlipping Matrix
Problems/Flipping Matrix

Flipping Matrix

Zomato / Eternal logoZomato / Eternal● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamples

Problem statement

You are given a 2N x 2N matrix of integers. You may reverse any row or any column any number of times and in any order.

Return the maximum possible sum of the upper-left N x N submatrix, covering rows 0 through N - 1 and columns 0 through N - 1.

Function

maxUpperLeftSubmatrixSum(matrix: int[][]) → int

Examples

Example 1

matrix = [[112,42,83,119],[56,125,56,49],[15,78,101,43],[62,98,114,108]]return = 414
matrix
0123011242831191561255649215781014336298114108

For each target cell in the upper-left quadrant, choose the largest value among the four cells that can be moved there by row and column reversals. The chosen values are 119, 114, 56, and 125, for a total of 414.

Source note: Source images are source-neutral excerpts of author-reported interview prompts.

More Zomato / Eternal interview questions

  • Find the Two Unique NumbersONSITE INTERVIEW · Seen Oct 2026
  • Jump Game IVONSITE INTERVIEW · Seen Oct 2026
  • LFU CacheONSITE INTERVIEW · Seen Aug 2026
  • Special KeyboardONSITE INTERVIEW · Seen Jul 2026
  • Detonate the Maximum BombsPHONE SCREEN · Seen Dec 2026
  • Friend Circles and Redundant ConnectionsPHONE SCREEN · Seen Sep 2026
  • Maximum Production Within PowerOA · Seen Jul 2026
  • Rearrange Songs by AuthorOA · Seen Jul 2026
  • Robot Warehouse OptimizationOA · Seen Jul 2026

Similar questions at other companies

  • Connected Crop GardenGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Balanced Human, Model and Task AssignmentOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Minimum Row Deletions to Prevent a Target ORInMobi · ONSITE INTERVIEWInMobi interview questions
  • Calculate the Max ValueAmazon · OA
  • Find Min Num MovesMicrosoft · OAMicrosoft interview questions
  • Best Starting Cell for Restaurant DistanceDoorDash · PHONE SCREENDoorDash interview questions
  • Server SelectionAirbnb · OAAirbnb interview questions
  • Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
  • Daily Temperature By TownTwo Sigma · OATwo Sigma interview questions
  • Town Temperature Regression AnalysisCitadel · PHONE SCREENCitadel interview questions
All Zomato / Eternal interview questionsSee Zomato / Eternal hiring insights
Saved
class Solution {
    public int maxUpperLeftSubmatrixSum(int[][] matrix) {
      // write your code here
    }
}
Checking account…