Create a mirror of an m–ary tree
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.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedAn 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.
Suppose you are given n red and n blue water jugs, all of different shapes and sizes. All red jugs hold different amounts of water, as do the blue ones. Moreover, there is a blue jug for every red jug that holds the same amount of water and vice versa.
Write an efficient algorithm to invert alternate levels of a perfect binary tree.
Write an efficient algorithm to construct a binary tree from given inorder and level-order sequence.
Given a string, find the minimum number of deletions required to convert it into a palindrome.
Given a linked list with each node having an additional random pointer that points to any random node of the linked list or null, update the random pointer in each linked list node to point to a node with maximum value to their right.
Write an efficient algorithm to construct a binary tree from the given inorder and postorder traversals.
Write an efficient code to clone a linked list with each node containing an additional random pointer. The random pointer can point to any random node of the linked list or null.
Given a binary search tree (BST), efficiently convert it into a min-heap. In order words, convert a binary search tree into a complete binary tree where each node has a higher value than its parent’s value.
Given a binary tree, convert it into a doubly-linked list following the spiral order.
This post will explore a threaded binary tree and convert a normal binary tree into a threaded binary tree.
Given an M × N matrix of integers whose each cell can contain a negative, zero, or a positive value, determine the minimum number of passes required to convert all negative values in the matrix positive.