Problem Statement
Given a boolean N*M matrix (that contains 0 and 1 only), you need to return the row number which has maximum no. of 1s in it.
Rows and columns are 0-indexed based. If more than one row has same number of 1s, print the row with lowest index.
Input Format :
Line 1 : N and M (space separated positive integers)
Next N lines : M elements of each row (separated by space).
Output Format :
Line 1 : Print row number
Constraints :
1 <= N <= 10^3
1 <= M <= 10^3
Note :
If more than 1 row have same number of 1s then print the smallest row number among them.
Sample Input 1 :
2 2
0 1
1 1
Sample Output 1 :
1
Previous
Next
Code:
https://ide.geeksforgeeks.org/ecbSyJ9WK1
why it is giving wrong ans
Maximum 1s problem
hello @anitagupta1411
size of a will not give u length of array a. it will give space occupied by array.
use n in place of sizeof(a)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.