Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Odd Even Linked List (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given the head of a singly linked list, rearrange the nodes such that all nodes with odd indices are grouped together followed by all nodes with even indices, and return the updated list

The order of the nodes within the odd and even groups should remain as in the original list.

The reordering should be done in-place with O(1) extra space and O(n) time complexity.

Examples

Example 1:

  • Input: head = [10, 20, 30, 40, 50, 60]
  • Expected Output: [10, 30, 50, 20, 40, 60]

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible