Problem
A linked list has an even number of nodes, n. Node i (0-based) and node n - 1 - i are twins: the first and last are twins, the second and second-to-last are twins, and so on. A twin sum is the sum of a node's value and its twin's value. Return the largest twin sum.
Example 1
- Input
- 5
- Output
- 4 -> 2 -> 1 → 6
- Why
- 5 + 1 = 6, 4 + 2 = 6
Example 2
- Input
- 4
- Output
- 2 -> 2 -> 3 → 7
- Why
- 4 + 3 = 7, 2 + 2 = 4
Example 3
- Input
- 1
- Output
- 100000 → 100001
Constraints
2 <= number of nodes <= 10^5The number of nodes is even.1 <= Node.val <= 10^5