• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 23, 2024 |560 Views
PROBLEM OF THE DAY : 22/04/2024 | Row with minimum number of 1's
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Nitin Kaplas . We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Matrix but also build up problem-solving skills.

In this problem, we are given,  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 :

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.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/row-with-minimum-number-of-1s5430/1

Read More