Maximum Twin Sum of a Linked List
MediumLinked List
Decode it first. Clues, constraints, pattern and plan before any code.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.
5 -> 4 -> 2 -> 1 → 6 (5 + 1 = 6, 4 + 2 = 6)
4 -> 2 -> 2 -> 3 → 7 (4 + 3 = 7, 2 + 2 = 4)
1 -> 100000 → 100001Constraints
2 <= number of nodes <= 10^5- The number of nodes is even.
1 <= Node.val <= 10^5