Back to problems

Insert into a Circular Linked List

Algorithm · Microsoft · Medium

You are given a circular linked list whose elements are already sorted in ascending order. Add a new node at the appropriate location so the list continues to follow its existing ordering. Your algorithm should run in O(n) time. When the list has no nodes, create and return a single self-contained node. Example Explanation: Because the input list is empty, the inserted value becomes the only node in the circular list.

Checking your access…