β Row Index Identification (Contest)
Row Index Identification (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework
// don't change the name of this class
// you can add inner classes if needed
class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int maxRow = 0;
long maxSum = Long.MIN_VALUE;
for (int i = 0; i < n; i++) {
long rowSum = 0;
for (int j = 0; j < m; j++) {
rowSum += sc.nextInt();
}
if (rowSum > maxSum) {
maxSum = rowSum;
maxRow = i + 1;
}
}
System.out.println(maxRow);
}
}
//method 02
```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework
// don't change the name of this class
// you can add inner classes if needed
class Main {
public static void main (String[] args)throws IOException {
// Your code here
Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String rowcol[] = br.readLine().split(" ");
int row = Integer.parseInt(rowcol[0]);
int col = Integer.parseInt(rowcol[1]);
long sum = 0;
long max = 0;
int index = 0;
String str[] = new String[row];
for(int i=0;i<row;i++)
{
str[i] = br.readLine();
}
int arr[][] = new int[row][col];
for(int i=0;i<row;i++)
{
String strArr[] = str[i].split(" ");
for(int j=0;j<col;j++){
arr[i][j] = Integer.parseInt(strArr[j]);
sum += arr[i][j];
}
if(sum>max)
{
index = i;
max = sum;
}
sum = 0;
}
System.out.print(index+1);
}
}
```Last updated