Grokking Amazon Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content

Largest Submatrix With Rearrangements (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

You are given a binary matrix matrix of size m x n. You are allowed to shuffle the columns of the matrix in any order.

Return the area of the largest submatrix, whose all elements are 1 after shuffling the columns of the matrix.

Examples

Example 1:

  • Input:
[[1,0,1],
 [1,1,1],
 [1,0,1]]
  • Expected Output: 6
  • Justification: By swapping the 2<sup>nd</sup> and 3<sup>rd</sup> columns, we can form a 2x2 rectangle of 1s. It forms the largest rectangle of 1s with an area of 6.

Example 2:

  • Input:
[[0,1],
 [1,1]]

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible