Find the maximum sum of a subsequence with no adjacent elements
Given an integer array, find the maximum sum of subsequence where the subsequence contains no adjacent elements.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an integer array, find the maximum sum of subsequence where the subsequence contains no adjacent elements.
Given an integer array, find all distinct combinations of a given length k, where the repetition of elements is allowed.
Given an integer array, find all distinct combinations of a given length k. The program should print only distinct combinations.
Given an integer array, replace each element with the product of every other element without using the division operator.
Given a BST, find the floor and ceil of a given key in it. If the given key lies in the BST, then both floor and ceil are equal to that key; otherwise, the ceil is equal to the next greater key (if any) in the BST, and the floor is equal to the previous greater key (if any) in the BST.
Given a BST and a positive number k, find the k’th largest node in the BST.
Given a BST and two nodes x and y in it, find the lowest common ancestor (LCA) of x and y. The LCA of x and y is the shared ancestor of x and y that is located farthest from the root.
Given a BST, find the inorder predecessor of a given key in it. If the key does not lie in the BST, return the previous greater key (if any) present in the BST.
Given two arrays that represent a set of BST keys, check if they represent the same BSTs or not. We are not allowed to build the tree.
Given a binary tree, calculate the sum of all nodes for each diagonal having negative slope (\). Assume that the left and right child of a node makes a 45–degree angle with the parent.
Given a binary tree, determine if it is a BST or not. This problem has a simple recursive solution. The BST property is the key to figuring out whether a tree is a BST or not.
Given an unsorted integer array that represents binary search tree keys, construct a height-balanced BST from it.