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...
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...
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...
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...
Binary tree and Binary search tree are defined as follows : Binary tree is a tree data structure in which each node has at most two child nodes. A binary search tree (BST) is...
Problem description : Implement a debounce function. For example, you wanted the mousmove function to be called only after 2 seconds has passed between mouse move events. A debounce function limits the rate at...
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...
Problem : Given a string and an array of words, find out if the input string can be broken into a space-separated sequence of one or more words. For example, inputDict = [“I” ,...
Backtracking is a general algorithmic technique that considers searching every possible combination in order to solve a problem. It is also known as depth-first search or branch and bound. It is an important tool...