Maximum Sum Subarray Problem (Kadane’s Algorithm)
Given an integer array, find a contiguous subarray within it that has the largest sum using Kadane’s algorithm.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an integer array, find a contiguous subarray within it that has the largest sum using Kadane’s algorithm.
The Longest Bitonic Subarray (LBS) problem is to find a subarray of a given sequence in which the subarray’s elements are first sorted in increasing order, then in decreasing order, and the subarray is as long as possible.
This post discusses std::next_permutation, which can be used to find the lexicographically greater permutations of a string.
Given an integer array containing duplicates, return the majority element if present. A majority element appears more than n/2 times, where n is the array size.
Given an integer array, in-place shuffle it. The algorithm should produce an unbiased permutation, i.e., every permutation is equally likely.
Given an array containing only 0’s, 1’s, and 2’s, sort it in linear time and using constant space.
Deletion from BST – write an efficient function to delete a given key in BST. To delete a node from BST, there are three possible cases to consider.
Given a BST, write an efficient function to search a given key in it. The algorithm should return the parent node of the key and print if the key is the left or right node of the parent node. If the key is not present in the BST, the algorithm should be able to determine that.
A Binary Search Tree (BST) is a rooted binary tree, whose nodes each store a key (and optionally, an associated value), and each has two distinguished subtrees, commonly denoted left and right.
Given a binary tree, write an iterative and recursive solution to traverse the tree using inorder traversal in C++, Java, and Python.
Given a binary tree, write an iterative and recursive solution to traverse the tree using preorder traversal in C++, Java, and Python.
Given a binary tree, write an iterative and recursive solution to traverse the tree using postorder traversal in C++, Java, and Python.