Find all employees who directly or indirectly reports to a manager
Given a map containing employee to manager mappings, find all employees under each manager who directly or indirectly reports him.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a map containing employee to manager mappings, find all employees under each manager who directly or indirectly reports him.
Write an efficient algorithm to find postorder traversal on a given binary tree from its inorder and preorder sequence.
Given an integer array, find subarrays with a given sum in it.
Given a binary tree, write an iterative algorithm to print the leaf-to-root path for every leaf node. Use of recursion is prohibited.
Given a binary search tree, find a pair with a given sum present in it.
Given a binary tree, write an efficient algorithm to compute the maximum number of nodes in any level in the binary tree.
Given a set S of positive integers, determine if it can be partitioned into three disjoint subsets that all have the same sum, and they cover S.
Given an array representing a binary tree, such that the parent-child relationship is defined by (A[i], i) for every index i in array A, build a binary tree out of it. The root node’s value is i if -1 is present at index i in the array.
Given an integer array, duplicates appear in it an even number of times except for two elements, which appear an odd number of times. Find both odd appearing elements without using any extra memory.
Given an unsorted integer array, find all pairs with a given difference k in it without using any extra space.
Given an unsorted integer array, print all pairs with a given difference k in it.
Given a sorted array containing duplicates, efficiently find each element’s frequency without traversing the whole array.