Skip to content

Instantly share code, notes, and snippets.

@kendhia
Created April 1, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kendhia/ae96626819cdcd1cd6b8641dd3aebdc1 to your computer and use it in GitHub Desktop.
Save kendhia/ae96626819cdcd1cd6b8641dd3aebdc1 to your computer and use it in GitHub Desktop.
package hackerank;
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numOfQueries = scanner.nextInt();
for (int i = 0; i < numOfQueries; i++) {
int numOfCustomers = scanner.nextInt();
int[] sumOfQueriesOfCustomer = new int[numOfCustomers];
int stingyValue = 100;
int stingyIndex = 0;
for (int j =0; j < numOfCustomers; j++){
for (int d = 0; d < numOfCustomers; d++){
sumOfQueriesOfCustomer[j] += scanner.nextInt();
}
if (sumOfQueriesOfCustomer[j] < stingyValue){
stingyValue = sumOfQueriesOfCustomer[j];
stingyIndex = j;
}
}
System.out.println(String.valueOf(stingyIndex+1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment