Row with maximum 1's(Contest)
Row with maximum 1's easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Row with maximum 1's easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Given a boolean matrix of size N*M in which each row is sorted your task is to print the index of the row containing maximum 1's. If multiple answer exist print the smallest one. Input First line contains two space separated integers denoting values of N and M. Next N lines contains M space separated integers depicting the values of the matrix.
Constraints:- 1 < = M, N < = 1000 0 < = Matrix[][] < = 1 Output Print the smallest index (0 indexing) of a row containing the maximum number of 1's. Example Sample Input:- 3 5 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1
Sample Output:- 0
Sample Input:- 4 4 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1
Sample Output:- 1
link: