Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Swap Nodes in Pairs

Difficulty: Medium

Acceptance: 65.00%

Points: 30.00

You are given the head of a singly linked list. Your task is to swap every two adjacent nodes without modifying the values stored in the nodes and return the head of the modified list. If the linked list contains an odd number of nodes, the last node remains unchanged.

Topics

Companies

Articles

Examples:

N/A

Constraints:
  • 1 = Number of nodes = 105
  • -10? = Node.data = 10
Companies:
Amazon
Topics:
Linked List
Locked Content
Access Restricted: Please Login to access the code editor and test cases.