Input: Goals Teams For Against Eng 5 10 Rus 10 11 USA 15 30 Bra 20 30 Ger 16 35 Jpn 12 20 Output : Rus
1. Initialize a String
variable to keep track of the team with mininum goal difference.
2. Store the absolute value of the difference between goals for
and goals against
for the first team and assume it to be the minimum.
3. Traverse through the statistics for each of the teams and keep updating the variable
created in step 1, which stores the team name by comparing it's data with the minimum difference obtained till now.
4. At the end of the loop
, return the team name.
public static String minGoalDiff(TeamData [] data) { }
C
Java
Python