Skip to content

Practice Maximum Twin Sum of a Linked List

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2130
LeetCode Problem

Maximum Twin Sum of a Linked List

Problem Statement

In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1. The twin sum is defined as the sum of a node and its twin. Given the head of a linked list with even length, return the maximum twin sum of the linked list.

Source: Maximum Twin Sum of a Linked List on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
head = [5,4,2,1]
Output
6

# Example 2

Input
head = [4,2,2,3]
Output
7

# Example 3

Input
head = [1,100000]
Output
100001

Constraints

The number of nodes in the list is an even integer in the range [2, 10^5].
1 <= Node.val <= 10^5

Related LeetCode Problems

Practice more problems similar to Maximum Twin Sum of a Linked List.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.