Problem
Submissions

Problem: Maximum Twin Sum of a Linked List

Statement

In a linked list with an even number of nodes (nn), each node at position ii (using 00−-based indexing) is paired with the node at position (n−1−in - 1 - i). These pairs are called twins for all 0≤i<n/20 ≤ i < n/2.

For example, if n=4n = 4, the twin pairs are:

  • The node at index 00 pairs with the node at index 33.

  • The node at index 11 pairs with the node at index 22.

The twin sum is the sum of a node’s value and its twin’s value. Given the head of a linked list with an even number of nodes, return the maximum twin sum among all pairs.

Constraints:

  • The list contains an even number of nodes in the range [2,103][2, 10^3].

  • 1≤1 \leq Node.value ≤103\leq 10^3

Problem
Submissions

Problem: Maximum Twin Sum of a Linked List

Statement

In a linked list with an even number of nodes (nn), each node at position ii (using 00−-based indexing) is paired with the node at position (n−1−in - 1 - i). These pairs are called twins for all 0≤i<n/20 ≤ i < n/2.

For example, if n=4n = 4, the twin pairs are:

  • The node at index 00 pairs with the node at index 33.

  • The node at index 11 pairs with the node at index 22.

The twin sum is the sum of a node’s value and its twin’s value. Given the head of a linked list with an even number of nodes, return the maximum twin sum among all pairs.

Constraints:

  • The list contains an even number of nodes in the range [2,103][2, 10^3].

  • 1≤1 \leq Node.value ≤103\leq 10^3