# Given two linked lists, both represent a number need to find its sum linked list.

As described in problem statement, we have two linked lists represents as decimal numbers. We aim to find its sum as a linked list. Let us understand this with an example. We can solve this problem in two different ways. Digit by digit sum calculation. Converting a list to the number and calculate the sumRead More »

# Find the Kth node from the end in a singly linked list.

The main drawback of a singly linked list is that we can not iterate it from backward. So, finding a node from the end in the singly-linked list is not as easy as we thought. First, we take a temporary node starting from the head and moves it to ‘K’ nodes from the head. NowRead More »

# Remove duplicate nodes in a singly linked list.

To remove duplicate in singly linked list firstly, to delete any node in a singly linked list, we need to have its previous node handle. Secondly, we need to identify the next node is duplicate or not. We will use a map to identify the next node duplicate or not by having the current nodeRead More »

# Find the middle element in a singly linked list.

We can find the middle element using the Rabbit and Tortoise method. Where we have two pointers, one jumps two steps(fast pointer), and the other jumps only once step(slow pointer) at once. Until the fast pointer reaches the end of the linked list, the slow would attain half of the linked list (which is theRead More »

# Find the number of occurrences of the given input in a linked list.

We are given a linked list of integers and an integer, which we want to calculate occurrences. We aim to find the count of events of the object in the linked list. To find the count of occurrences, we simply iterate over each item and checks if the current thing is equivalent to the givenRead More »

# Reverse alternate group of K nodes in a singly linked list

Consider we have a singly linked list of “N” nodes, in which we aim to reverse alternate “K” nodes. Let’s see the below pictorial representation of a singly linked list. Here, our input linked list of size 7 nodes is 10->20->30->40->50->60->70->NULL and we want to reverse every alternative 3 (K) nodes group, pictorial representation ofRead More »

# Easily Merge Two Sorted Linked Lists!

We can combine two sorted linked lists into one sorted singly-linked list by first comparing the head nodes of each list. We take the smaller of the two values and add it to the final linked list. By repeating this process for each node in both lists, we can merge them together in a sortedRead More »

# Clone singly-linked list with next an arbitrary pointer

Given a singly linked list that contains next and arbitrary pointers, the aim is to make a clone of that linked list. An example list with each node contains the next and the random pointer is as shown below. We can solve this problem in a 3 step process as described in the below pictures.Read More »

# Check if singly linked list palindrome or not

Given a linked list with integer or character data, check if given singly linked list palindrome or not. The below picture shows how a palindromic singly linked list looks like. Reversing palindromic singly list gives the same list back again. There are many ways to solve this problem, Here I want to explain the threeRead More »

# Find loop in a singly linked list

Given a Singly linked list with N nodes, in which a loop exists with ‘R’ number of nodes. We aim to find the starting point of the loop. Let’s see the example below for a better understanding. I consider this as a bit math puzzle than a programming question. Now let’s try to find aRead More »

# How to reverse the given singly linked list

Given a singly linked list, the aim is to reverse the linked list. Reversing a singly linked list is one of the most common and basic interview questions. This problem is a test for your ability to understand pointers. Let’s take an example and see how it goes. Below are two possible solutions to thisRead More »

# Unlock the Decimal Equivalent of a Binary Linked List!

A Binary Linked List is a type of data structure where each node in the list contains either a 0 or 1. In this article, we’ll explore how to convert a Binary Linked List into its decimal equivalent number. To better understand the concept, let’s take a look at an example. The Iterative and RecursiveRead More »

# Doubly Linked List data structure

Doubly linked list is the list that most programming languages uses in their libraries (like, java lists, c++ lists…etc). The problem with linked lists is that we can’t move backward from any respective node. To overcome this problem Doubly Linked Lists (DLL) comes into the picture. Unlike nodes in linked lists here Node has twoRead More »

# Singly Linked List data structure

Major drawback while inserting, deleting into arrays is to shift all elements right side when insert or delete element to satisfy arrays continuous memory policy. Linked List data structure came up with random memory linking of nodes to overcome the above shifting problem. These nodes can be linked/chained to the next node memory location, theRead More »