Row with minimum number of 1's GFG POTD Python Solution geeks for geeks problem of the day
VS Code VS Code
218 subscribers
73 views
0

 Published On Apr 21, 2024

Problem - https://www.geeksforgeeks.org/problem...

Given a 2D binary matrix(1-based indexed) a of dimensions nxm , determine the row that contains the minimum number of 1's.
Note: The matrix contains only 1's and 0's. Also, if two or more rows contain the minimum number of 1's, the answer is the lowest of those indices.

Example 1:

Input:
n = 4,m = 4
a = [[1, 1, 1, 1],
[1, 1, 0, 0],
[0, 0, 1, 1],
[1, 1, 1, 1]]
Output:
2
Explanation:
Rows 2 and 3 contain the minimum number
of 1's(2 each).Since,row 2 is less than row 3.
Thus, the answer is 2.
Example 2:

Input:
n = 3,m = 3
a = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
Output:
1
Explanation:
All the rows contain the same number
of 1's(0 each).Among them, index 1
is the smallest, so the answer is 1

show more

Share/Embed