less than 1 minute read

Given a singly linked list node, swap each pair of nodes and return the new head.

Constraints

  • n ≤ 100,000 where n is the number of nodes in node

https://binarysearch.com/problems/Pairwise-Linked-List-Swap

Examples

Example 1

Input

  • node =

Output

  • answer =

Example 2

Input

  • node =

Output

  • answer =

Solution

Leave a comment