For this Question: 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.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[][] < = 1Print the smallest index (0 indexing) of a row containing the maximum number of 1's.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, I have written this Solution Code:     // mat is the matrix/ 2d array
    // n,m are dimensions
    function max1Row(mat, n, m) {
        // write code here
        // do not console.log
        // return the answer as a number

        let j, max_row_index = 0;
        j = m - 1;

        for (let i = 0; i < n; i++)
        {
         
            // Move left until a 0 is found
            let flag = false;
             
            // to check whether a row has more 1's than previous
            while (j >= 0 && mat[i][j] == 1)
            {
             
                j = j - 1; // Update the index of leftmost 1
                // seen so far
                flag = true;//present row has more 1's than previous
            }
             
            // if the present row has more 1's than previous
            if (flag)
            {
                max_row_index = i; // Update max_row_index
            }
        }
        if (max_row_index == 0 && mat[0][m - 1] == 0)
            return -1;
        return max_row_index;
    }



, In this Programming Language: JavaScript, Now tell me if this Code is compilable or not?