Find the minimum depth of a binary tree
Given a binary tree, find its minimum depth. The minimum depth is the total number of nodes along the shortest path from the root node down to the nearest leaf node.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary tree, find its minimum depth. The minimum depth is the total number of nodes along the shortest path from the root node down to the nearest leaf node.
Given a list containing future price predictions of two different stocks for the next n–days, find the maximum profit earned by selling the stocks with a constraint that the second stock can be sold, only if no transaction happened on the previous day for any of the stock.
An m-ary tree is a tree in which each node has no more than m children. Given an m-ary tree, write an efficient algorithm to convert the tree to its mirror.
Given a valid roman numeral, convert it to the corresponding integer value.
Given a string representing the column name in an Excel sheet, return the number corresponding to the Excel column name.
Given two integers, return the Hamming distance between the two. The Hamming distance is the total number of places where the corresponding bits are different in the binary representation of two integers.
Given a positive number, check if it is a perfect square without using any built-in library function. A perfect square is a number that is the square of an integer.
The Longest Alternating Subarray is a problem of finding a subarray with alternating positive and negative elements, and in which the subarray is as long as possible.
Given an array and a positive number k, check whether the array contains any duplicate elements within the range k. If k is more than the array’s size, the solution should check for duplicates in the complete array.
Given an unsorted integer array, print all greater elements than all elements present to their right.
Given a limited range array of size n and containing elements between 1 and n+1 with one element missing, find the missing number without using any extra space.
Compute modulus division of a positive number n by another positive number d which is a power of 2 without using division or modulo operator.