import 'dart:io';
class MyClass
{
static int FindRowWithMaximumOnes(List<List<int>>matrix) {
if (matrix.length == 0) {
return -1;
}
var rows = matrix.length;
var cols = matrix[0].length;
var row_index = -1;
var max_count = 0;
for (var i = 0; i < rows; i++) {
var count = 0;
for (var j = 0; j < cols; j++) {
if (matrix[i][j] == 1) {
count++;
}
}
if (count > max_count) {
max_count = count;
row_index = i;
}
}
return row_index;
}
static void main()
{
List<List<int>> matrix = [ [0, 0, 0, 0, 1, 1],
[0, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 0, 1],
[0, 1, 1, 1, 0, 1],
[0, 0, 0, 1, 1, 1] ];
stdout.write("Row index = " + MyClass.FindRowWithMaximumOnes(matrix).toString());
}
}
void main(List< String > args){
MyClass.main();
}
/*
run:
Row index = 3
*/