Associated Course(s):
Sudo Placement 2019

Given a binary matrix, Your task is to complete the function **maxArea** which the maximum size rectangle area in a binary-sub-matrix with all 1’s. The function takes 3 arguments the first argument is the Matrix M[ ] [ ] and the next two are two integers n and m which denotes the size of the matrix M. Your function should return an integer denoting the area of the maximum rectangle .

**Input:**

The first line of input is an integer T denoting the no of test cases . Then T test cases follow. The first line of each test case are 2 integers n and m denoting the size of the matrix M . Then in the next line are n*m space separated values of the matrix M.

**Output:**

For each test case output will be the area of the maximum rectangle .

**Constraints:**

1<=T<=50

1<=n,m<=50

0<=M[][]<=1

**Example:
Input**

1

4 4

0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0

8

For the above test case the matrix will look like

0 1 1 0

1 1 1 1

1 1 1 1

1 1 0 0

the max size rectangle is

1 1 1 1

1 1 1 1

and area is 4 *2 = 8

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

hardikJain5 | 110 |

CodeBuddy | 107 |

Akkki111 | 100 |

saurabhgrade1 | 98 |

WrongAnswer | 80 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1103 |

mazumderrohit8 | 1095 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4566 |

Quandray | 4444 |

Login to report an issue on this page.