This is what I have so far, but its not printing anything. Maybe im not adding the map right , or to the list im not sure.
public static List smallestNegativeBalance(List<List> debts) {
List<String> list = new ArrayList<>();
Map<String, Integer> map = new HashMap<>();
for(List<String> str: debts){
String borrower = (str.get(0));
String lender =(str.get(1));
Integer amount = new Integer(str.get(2));
if(map.containsKey(lender)){
// lender+= Integer.parseInt(amount);
map.put(lender, amount);
// map.putIfAbsent(lender, lender.indexOf(2));
if(map.containsKey(borrower)){
map.remove(borrower);
}
Integer min = Collections.min(map.values());
Collections.sort(list);
for (Map.Entry<String, Integer> map2 : map.entrySet()) {
if(map2.getValue() >= 0){
System.out.println("Nobody has a negative balance");
}if(map2.getValue() == min ){
list.add(map2.getKey());
// list.add(map2, map.get(0).get(2));
}
}
}
}
return list;
} }