# Problem Link

**Setter:** Trung Nguyen

**Tester:** Hasan Jaddouh

**Editorialist:** Bhuvnesh Jain

# Difficulty

CAKEWALK

# Prerequisites

Looping Techniques

# Problem

Find the team with the maximum number of goals, or report if there is a “Draw”.

# Explanation

The problem simply states to count the number of goals scored by each team and report the name of the winner team. Thus, if the first team scores x goals, then the other team scores (N - x) goals (because the total number of goals scored were N). Clearly, the winner is the one with the higher number of goals. To count the number of goals by the first team, we simply iterate through the list of team which scored the next goal and compare if it has the same name as the first team, then, we increment the counter. Now, we simply check using “If” conditions, whether the first team won or the second team won or there is a draw.

The time complexity of this approach will be the sum of length of strings in input (per test case) as each string comparison takes a total of O(\text{length of string}). This is the most optimal algorithm for even taking the input takes same time asymptotically.

For details, refer to the editorialist solution below.

# Time Complexity

O(\sum_{i=1}^{i=N} |S_i|), per test case, where |S| = length of string S.

# Space Complexity

O(N)