## Count rotations in sorted and rotated linked list

Given a linked list of n nodes which is first sorted, then rotated by k elements. Find the value of k. Recommended: Please try your… Read More »

Given a singly linked list, we have to convert it into circular linked list. For example, we have been given a singly linked list with… Read More »

## Rotate Linked List block wise

Given a Linked List of length n and block length k rotate in circular manner towards right/left each block by a number d. If d… Read More »

## Josephus Circle using circular linked list

There are n people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around… Read More »

## Insert a node after the n-th node from the end

Insert a node x after the nth node from the end in the given singly linked list. It is guaranteed that the list contains the… Read More »

## Sort a linked list of 0s, 1s and 2s by changing links

Given a linked list of 0s, 1s and 2s, sort it. Examples: Input : 2->1->2->1->1->2->0->1->0 Output : 0->0->1->1->1->1->2->2->2 Input : 2->1->0 Output : 0->1->2 Recommended:… Read More »

## Merge two sorted lists (in-place)

Given two sorted lists, merge them so as to produce a combined sorted list (without using extra space). Examples: Input : head1: 5->7->9 head2: 4->6->8… Read More »

## Insert node into the middle of the linked list

Given a linked list containing n nodes. The problem is to insert a new node with data x at the middle of the list. If… Read More »

## Construct a linked list from 2D matrix

Given a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node. Example: Input… Read More »

## Find modular node in a linked list

Given a singly linked list and a number k, find the last node whose n%k == 0, where n is the number of nodes in… Read More »

## Find the fractional (or n/k – th) node in linked list

Given a singly linked list and a number k, write a function to find the (n/k)-th element, where n is the number of elements in… Read More »

## Reverse a Linked List in groups of given size | Set 2

Given a linked list, write a function to reverse every k nodes (where k is an input to the function). Examples: Inputs: 1->2->3->4->5->6->7->8->NULL and k… Read More »

## Count nodes in Circular linked list

Given a circular linked list, count number of nodes in it. For example output is 5 for below list. Recommended: Please try your approach on… Read More »

## Find length of loop in linked list

Write a function detectAndCountLoop() that checks whether a given Linked List contains loop and if loop is present then returns count of nodes in loop.… Read More »

## An interesting method to print reverse of a linked list

We are given a linked list, we need to print the linked list in reverse order. Examples: Input : list : 5-> 15-> 20-> 25… Read More »