Given the head pointer of a linked list, check if there’s a loop in the linked list. Return true if there’s a loop.
Floyd’s Cycle-Finding Algorithm (Proof)

The problem statement is: Given the head pointers (head1 and head2 ) of two linked lists, find the intersection node of the two lists. For the above image, program needs to output: 4 as the intersection point. Naive Approach Run two for loops: outer loop from 0 to head1.length() and inner […]

The C++ Standard Template Library (STL) is a powerful library of C++ template classes that provide general-purpose classes and functions. It has implementations of many popular and commonly used algorithms and data structures like vectors, linked-lists, queues, priority queues, and stacks. In this post we’ll learn about: linked-lists. Linked List To […]

You are given a pointer to a node of a linked list which is to be deleted. You neither have a head pointer nor the pointer to the previous node. As we have seen in this post, deleting a node from a linked list require a pointer to the previous node. […]

A Linked List is a data structure in which the objects are arranged in a linear order. Unlike Arrays, you cannot access any element directly through its index. Time complexity of access operation in Linked lists is O(n) where n is the size of linked list. Also unlike an array, Linked […]