n whose first node is first. Nodes are numbered from zero.
Node i and node n - 1 - i form a *mirror pair*: the first with the last, the second with the second-to-last, and so on. The sum of a pair is the sum of its two node values.
Return the largest sum over all mirror pairs.first=list_node([3, 8, 1, 6]) → 9
The pairs are the first and last nodes, 3 + 6 = 9, and the second and third, 8 + 1 = 9. The maximum is 9.
first=list_node([2, 10, 4, 7, 1, 5]) → 11
The pairs are 2 + 5 = 7, 10 + 1 = 11 and 4 + 7 = 11. The answer is 11.
first=list_node([50, 50]) → 100
first=list_node([3, 8, 1, 6])
9
Run checks the first 3 tests in your browser. Submit checks all 81 tests on the server, hidden ones included.