Row with max 1s
Submissions: 7961   Accuracy:

33.57%

  Difficulty: Medium   Marks: 4
Associated Course(s):   Interview Preparation

Given a boolean 2D array where each row is sorted. Find the row with the maximum number of 1s.

Input:
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case contains n and m, where n is the number of rows and m is the number of columns. The second line of each test case contains the array elements.

Output:
Print the row with the maximum number of 1s.

Constraints:
1 ≤ T ≤ 50
1 ≤ n,m ≤ 103

Example:
Input:
1
4 4
0 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0

Output:
2

Explanation :
Testcase 1 : Row 2 is having maximum number of 1s (0-based indexing).

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.