Remove all nodes from a linked list that matches a given key
Given a linked list, remove all nodes from it that match a given key.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a linked list, remove all nodes from it that match a given key.
Given a positive integer n and a target, find all combinations of distinct numbers in the interval [1,9] of length n that add up to the target.
Given a binary tree and an integer k, count the total number of paths in the tree whose sum of all nodes is equal to k.
Given an integer array, shrink it by removing adjacent triplets that satisfy the given constraints and return the total number of elements in the resultant array.
Given a BST, count the total number of nodes that lie within a given range.
An Eulerian trail (or Eulerian path) is a path in a graph that visits every edge exactly once. Given a directed graph, check whether it has an Eulerian path or not.
Given a linked list, construct a complete binary tree from it. Assume that the order of elements present in the linked list is the same as that in the complete tree’s array representation.
Given a binary tree, check if removing an edge can split it into two binary trees of equal size.
Given two height-balanced binary search trees, in-place merge them into a single balanced binary search tree. For each node of a height-balanced tree, the difference between its left and right subtree height is at most 1.
Given an array representing the parent-child relationship in a binary tree, find the tree’s height without building it. The parent-child relationship is defined by (A[i], i) for every index i in array A.
Given a binary tree and two tree pointers, x and y, write an efficient algorithm to check if they lie on the same root-to-leaf path in the binary tree. In other words, determine whether x is an ancestor of y, or x is a descendant of y.
Given r red, b blue, and g green balls, find the total number of arrangements in a row such that no two balls of the same color end up together.