# Category: Linked List

## Merge Two Sorted Linked Lists in Javascript

Problem : Given list l1 = 1->2->3. And list l2 = 10->20->30. Generate a new list mergedList = 1->2->3->10->20->30. Given list l1 = 1->3->4. And list l2 = 1->2->3. Generate a new list mergedList...

## Detect start of a loop in linked list

Problem : Given a linked list, implement an algorithm which returns the node at the beginning of the loop. This post is a follow-up of – JavaScript Linked List Example – Detect a loop...

## Find loop length in a cyclic/circular linked list

Input : A linked list Output: An integer This post is a follow-up of – JavaScript Linked List Example – Detect a loop in cycliccircular linked list. I recommend reading those posts first, as...

## Detect a loop in cyclic/circular linked list

Logic : If a linked list has a cycle then no node has a null as next pointer. A simple loop exists when p1.next.next !== null as shown below. While iterating over the linked...

## Given the binary tree create linked lists of the nodes at the same level

Problem description : Convert a given binary tree to a linked list of all the nodes at each depth (if you have a binary tree with depth D, you’ll have D linked lists). Logic...

## Given a singly linked list find if it is palindrome

Problem description : Write a function to determine if a singly linked list is a palindrome. Input : A linked list Output : Boolean (true or false) Approach 1: Reverse and compare the linked...

## Reverse a singly linked list

Problem description : Write a function to reverse a singly linked list. Input : A linked list Output : A linked list Logic : Iterate through linked list with three-pointers previous, current, next. While...

## Partition a linked list around a value

Problem description : Write code to partition a linked list around a value val, such that all nodes less than val come before all nodes greater than or equal to val. Input : A...

## Find the kth to last element of a singly linked list

Problem description : Implement a non-recursive algorithm to find the kth to last element of a singly linked list. Input : A linked list Output : A value of a node in a linked...

## Delete a node from a linked list in javascript

Problem description : Write a method to remove a node from a linked list. Input: A linked list Output: A linked list with one less node Logic : Iterate through the list, if you...