## Convert BST to Greater Sum Tree

Objective: Given a binary search tree (BST), convert it into greater sum tree. What is greater sum tree: Greater sum tree is a tree in which every node contains the sum of all the...

Objective: Given a binary search tree (BST), convert it into greater sum tree. What is greater sum tree: Greater sum tree is a tree in which every node contains the sum of all the...

Objective: Given a linked list and a number ‘k’, write an algorithm to reverse alternate ‘k’ nodes in the linked list. This problem was asked in the Microsoft and Amazon interviews. Example: Approach: Recursion...

Objective: Given a linked list and integer ‘k’, write an algorithm to reverse the linked list in groups of size ‘k’. Example: Approach: Earlier we have seen how to reverse a linked list, solution...

Objective: Given ‘N’ windows where each window contains certain number of tickets at each window. Price of a ticket is equal to number of tickets remaining at that window. Write an algorithm to sell...

Objective: Given a binary tree, write an algorithm to convert it into its Sum tree. What is Sum tree: Sum tree of a binary tree, is a tree where each node in the converted...

Objective: Given a rope of length n meters, write an algorithm to cut the rope in such a way that product of different lengths of rope is maximum. At least one cut has to...

Objective: Given two string sequences write an algorithm to find, find the length of longest substring present in both of them. This problem has been asked in Amazon and Microsoft interviews. Approach to solve...

Objective: Given two string sequences, write an algorithm to find the length of longest subsequence present in both of them. These kind of dynamic programming questions are very famous in the interviews like Amazon,...

Objective: Given a rod of length n inches and a table of prices pi, i=1,2,…,n, write an algorithm to find the maximum revenue rn obtainable by cutting up the rod and selling the pieces....

Objective: Given a set of coins and amount, Write an algorithm to find out how many ways we can make the change of the amount using the coins given. This is another problem in...

Objective: Given a 2D-matrix where each cell has a cost to travel. You have to write an algorithm to find a path from left-top corner to bottom-right corner with minimum travel cost. You can...

Objective: Print All N Length Strings from Given String of Length K where characters can appear multiple time. Example: String k = “ALGO” N=2 Result: AA LA GA OA AL LL GL OL AG...

Objective: Generate Well Ordered Passwords of a Given Length K. Well ordered means that digits should be in increasing order in every generated password. Example: K = 7 1234567 1234568 1234569 1234578 1234579 1234589...

Objective: Given a matrix of 0’s and 1’s (binary matrix). Find out Maximum size square sub-matrix with all 1’s. Example: Approach: Base Cases: If only one row is given then cells with 1’s will...

Objective: The longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence in a given array such that all elements of the subsequence are sorted in increasing order. OR Given...

%d bloggers like this: