Binary Matrix
Tag(s):

## Algorithms, Greedy Algorithms, Implementation, String Manipulation

Problem
Editorial
Analytics

N numbers were converted into their respective Binary form of M length and arranged in an NxM matrix.

Your task is to find the index of row (1 based indexing) which contains the binary number with maximum value. If multiple rows have maximum value then print the row with minimum index.

Input:

The first line contains two space separated integers N and M, denoting number of rows and number of columns in matrix respectively.

Each of the next N lines contains a number in binary form.

Output:

Print the index of row in a single line.

Constraints:

$1 \le N,M \le 10^3$
$0 \le mat[i][j] \le 1$

SAMPLE INPUT
4 4
1010
0100
0010
0011
SAMPLE OUTPUT
1
Explanation

1st row value  =  2*1  +  2*0 + 21 *1 + 2*0  =  10

2nd row value =  2*0  +  2*1 + 21 *0 + 2*0  =  4

3rd row value  =  2*0  +  2*0 + 21 *1 + 2*0  =  2

4th row value  =  2*0  +  2*0 + 21 *1 + 2*1  =  3

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, Java 14, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, R(RScript), Racket, Ruby, Rust, Scala, Swift-4.1, Swift, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

Capillary Software Developer Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
• Basic Programming > Implementation
• Algorithms > Dynamic Programming