Evaluate a given expression
Given an expression containing numeric operands with addition and subtraction operators, evaluate it. The expression may contain sub-expressions enclosed in opening and closing braces.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an expression containing numeric operands with addition and subtraction operators, evaluate it. The expression may contain sub-expressions enclosed in opening and closing braces.
A string that may contain multiple consecutive instances of the same value is encoded to only store that value and its count. Given such an encoded sequence, decode it.
Given a binary tree and an integer k, count the total number of paths in the tree whose sum of all nodes is equal to k.
Given an integer array, shrink it by removing adjacent triplets that satisfy the given constraints and return the total number of elements in the resultant array.
Given two height-balanced binary search trees, in-place merge them into a single balanced binary search tree. For each node of a height-balanced tree, the difference between its left and right subtree height is at most 1.
Given r red, b blue, and g green balls, find the total number of arrangements in a row such that no two balls of the same color end up together.
Given an integer array, truncate it such that 2×min becomes more than max, and the total number of removals is minimal. The elements can be removed either from the start or end of the array if the above condition does not meet.
Given a set of words, check if the individual words can be rearranged to form a circle. Two words, X and Y, can be put together in a circle if the last character of X is the same as the first character of Y or vice-versa.
Given a rectangular binary matrix, calculate the area of the largest rectangle of 1’s in it. Assume that a rectangle can be formed by swapping any number of columns with each other.
Given a directed graph, check if it is possible to construct a cycle that visits each edge exactly once, i.e., check whether the graph has an Eulerian cycle or not.
Given two binary trees, check whether the leaf traversals of both trees are the same or not.
Given a binary tree, write an efficient algorithm to find the maximum path sum between any two nodes in it. The path can start and end at any node in the tree and need not go through the root.