Find all duplicate elements in a limited range array
Find the duplicate numbers in an integer array of size n that contains elements between 1 and n, at least one of which repeats.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedFind the duplicate numbers in an integer array of size n that contains elements between 1 and n, at least one of which repeats.
Given a linked list, remove all nodes from it that match a given key.
Given a binary matrix in which the values 0 and 1 correspond to land and water, respectively, and the connected ones form exactly one island, find the perimeter of an island.
Given a string, find the length of the longest palindrome possible from its characters.
Given a positive number n, construct an integer array of length n where each index stores the count of 1’s in the binary representation of the index.
Given two strings, check if the second string can be constructed from characters of the first string, where each character of the first string can be used only once in the second string.
Given two strings, check if the second string is a subsequence of the first string.
Given the root of a binary tree, determine if the binary tree holds children-sum property. For a tree to satisfy the children-sum property, each node’s value should be equal to the sum of values at its left and right node.
Given a BST, count the total number of nodes that lie within a given range.
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 an array representing the preorder traversal of a BST, determine whether it represents a skewed BST or not. In a skewed BST, each node’s descendants are either smaller or larger than the node itself.