We are given a binary tree. The goal is to find the maximum length cycle in the given tree. We will do this by finding the maximum height of the left subtree and right subtree from the root node and will join these maximum length paths to get the longest ... Read More
We are given the Inorder and Preorder traversals of a binary tree. The goal is to construct a tree from given traversals.Inorder traversal − In this type of tree traversal, a left subtree is visited first, followed by the node and right subtree in the end.Inorder (tree root)Traverse left subtree ... Read More
A Continuous Tree is defined as a tree with any path from root node to leaf node has value or weight of nodes such that the absolute difference between the parent node and all of its direct children nodes is always 1.If we pick any node on the path from ... Read More
Derangement is permutation of N numbers such that no number appears at original position. For example one possible derangement of { 1, 2, 3 } is { 2, 1, 3 }. No element in this is at its original position. The goal here is to count the possible derangements for ... Read More
If we go by the term Content Management System word to word, then it basically means a system of managing the content. It is defined as a collaborative platform with different features and functionalities that allow the creating, designing, publishing and maintaining web content easily and effectivelWhat is a Content ... Read More
We are given a string containing (, ), {, }, [, ] characters only. The goal is to find the maximum length of such string so that it becomes balanced by swapping adjacent characters or removing a character. We will do this by comparing adjacent characters, if they are opposite ... Read More
We are given N rupees. The goal is to buy maximum water possible with the money where the rates of water bottles are as follows −Plastic Bottles: A Rupees for 1 litreGlass Bottles: B Rupees for 1 litreGlass Bottles: B Rupees for 1 litreNow the original cost of glass bottles ... Read More
We are given an array of numbers say Arr1[] and another array Arr2[] of same or different length. The Arr1[] has elements sorted in ascending order, such that a single element is unsorted. We must find the element from the second array Arr2[] such that it can replace the wrongly ... Read More
Turing Machine − A Turing machine is a device used to accept words of a language generated by type 0 grammars. A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which ... Read More
We are given with a matrix of numbers. The goal is to find the number of Magic squares present inside the given matrix.A Magic Square, if taken as a matrix, is a 3X3 matrix which contains the elements ranging from 1 to 9 just like a grid in Sudoku. Properties ... Read More