Update every key in a BST to contain the sum of all greater keys
Given a binary search tree, modify it such that every key is updated to contain the sum of all greater keys present in the BST.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary search tree, modify it such that every key is updated to contain the sum of all greater keys present in the BST.
Given a positive integer n, print all combinations of numbers between 1 and n having sum n.
Print binary representation of a given number in C, C++, Java, and Python using built-in methods and custom routines.
Write a program to count the number of ways to calculate a target number from the specified array elements using only addition and subtraction operator. The use of any other operator is forbidden.
Given n lists of words, print all combinations of phrases that can be formed by picking one word from each list.
Given a linked list, rearrange it by separating odd nodes from even ones. All even nodes should come before all odd nodes in the output list, and the relative order of even and odd nodes should be maintained.
Given a binary tree, find the maximum difference between a node and its descendants in it.
Given a binary tree, efficiently clone of it.
Given an M × N matrix where each cell contains a coin of some denomination, collect the maximum value of coins by traversing the grid.
Given an M × N rectangular grid, efficiently count all paths starting from the first cell (0, 0) to the last cell (M-1, N-1). We can either move down or move towards right from a cell.
Given an M × N rectangular grid, print all shortest routes in the grid that start at the first cell (0, 0) and ends at the last cell (M-1, N-1). We can move down or right or diagonally (down-right), but not up or left.
Given a monotonically increasing function f(x) on the non-negative integers, find the value of x, where f(x) becomes positive for the first time. In other words, find a positive integer x such that f(x-1), f(x-2), … are negative and f(x+1), f(x+2), … are positive.