Created
February 12, 2018 00:09
-
-
Save tapannallan/274ea12918529e5311b8d88a9fc01f8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Map; | |
/** | |
* Average Expense Calculator | |
*/ | |
public class Average_Expense_Calculator { | |
public Integer average(Map<String, List<Integer>> expenses) { | |
int totalExpenses = expenses.values().stream().flatMap(Collection::stream).mapToInt(Integer::intValue).sum(); | |
return totalExpenses / expenses.size() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment