Problem Statement: You are given a number and integer k. You need to remove k digits from the number and it should return the smallest integer possible. Example Input: num = "10300", k = 1 Output: "300" Here if you remove the leading "1", the o/p …
Problem Statement: You are given sorted array, and an integer K. You need to add elements in such a way that any number in the range inclusive can be formed by the sum of the some of the elements in the array. You need to return …
Problem Statement: You are given a string s, you need to remove duplicate letters so that every letter should appear only once. The result should be in smallest lexicographical order Example Input: s = "bcabcccdd" Output: "abcd" Solution The solution is very simple: 1. …
Problem Statement: You are given a root node of a BST. You need to check if it has a dead end or not. A dead end is a node, where you will not be able to insert any other nodes after it. BST should contain +ve …
Problem Statement: You are given an array of integers in pre-order fashion. Then you need to check if it is a valid BST. Solution pre-order means, root element, followed by left sub-tree, followed by right sub-tree. First we will construct a BST from the given sequence. …
Problem Statement: You are given a BST node and a key. YOu need to find if that key exist any triplet sum in given BST. Solution We do in-order traversal of the BST, we get the sorted order and store in an array. Then we have …
Problem Statement: You are given an DLL where the nodes are sorted in ascending order. we need to construct Balanced BST in-place. In-place means, no new nodes should be allocated for tree conversion. Solution Below are the steps to be followed to arrive at the solution: …
Solution The solution is very simple. For every node visited, check if the node lies in range, if yes, then increment the count. Then recursion for both of its children. If the current node is smaller than low value, then recursion the right child, else recursion …