Tap here to switch tabs
Problem
Submissions

Problem: Winner of the Linked List Game

Try to solve the Winner of the Linked List Game problem.

Statement

You are given the head of a linked list of even length.

The list is partitioned into consecutive pairs of adjacent nodes: the node at index 2⋅i2 \cdot i and the node at index 2⋅i+12 \cdot i + 1 for i≥0i \geq 0, using 00 based indexing.

In each pair, a game is played between the Even team and the Odd team:

  • If the value of the even indexed node is strictly greater than the value of the odd indexed node, the Even team scores 11 point.

  • If the value of the odd indexed node is strictly greater than the value of the even indexed node, the Odd team scores 11 point.

Return "Even" if the Even team has more points than the Odd team, "Odd" if the Odd team has more points than the Even team, or "Tie" if both teams have an equal number of points.

Constraints:

  • The number of nodes in the list is in the range [2,100][2, 100].

  • The number of nodes in the list is even.

  • 1≤1 \leq Node.val ≤100\leq 100

  • The value of each odd indexed node is odd.

  • The value of each even indexed node is even.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Winner of the Linked List Game

Try to solve the Winner of the Linked List Game problem.

Statement

You are given the head of a linked list of even length.

The list is partitioned into consecutive pairs of adjacent nodes: the node at index 2⋅i2 \cdot i and the node at index 2⋅i+12 \cdot i + 1 for i≥0i \geq 0, using 00 based indexing.

In each pair, a game is played between the Even team and the Odd team:

  • If the value of the even indexed node is strictly greater than the value of the odd indexed node, the Even team scores 11 point.

  • If the value of the odd indexed node is strictly greater than the value of the even indexed node, the Odd team scores 11 point.

Return "Even" if the Even team has more points than the Odd team, "Odd" if the Odd team has more points than the Even team, or "Tie" if both teams have an equal number of points.

Constraints:

  • The number of nodes in the list is in the range [2,100][2, 100].

  • The number of nodes in the list is even.

  • 1≤1 \leq Node.val ≤100\leq 100

  • The value of each odd indexed node is odd.

  • The value of each even indexed node is even.