menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Matrix: Fi...
source image

Prodevelopertutorial

1M

read

234

img
dot

Matrix: Find a row with maximum number of 1’s in a binary matrix

  • You are given a m*n binary matrix, you need to find a row that has maximum number of 1’s in it.
  • Two approaches to solve this problem: Brute force approach and Binary Search approach.
  • Brute force approach: Traverse the matrix row by row and count the number of 1s in each row. Return the row with the maximum number of 1s.
  • Binary Search approach: Since each row is sorted, use binary search to find the first instance of 1 in each row. Return the row with the maximum number of 1s.

Read Full Article

like

14 Likes

For uninterrupted reading, download the app