## Count all subsequences having product less than K

The problem “Count all subsequences having product less than K” states that you are given an array of integers. Now find the number of subsequences that have a product less than a given input K. Example   a[] = {1, 2, 3, 4, 5} k = 8 Number of subsequences less …

## Letter Combinations of a Phone Number

In letter combinations of a phone number problem, we have given a string containing numbers from 2 to 9. The problem is to find all the possible combinations that could be represented by that number if every number has some letters assigned to it. The assignment of the number is …

## Sum of minimum and maximum elements of all subarrays of size k

Problem Statement   The problem “Sum of minimum and maximum elements of all subarrays of size k” states that you are given an array containing positive and negative integers, find the sum of minimum and maximum elements of all the sub-arrays of size k. Examples   arr[] = {5, 9, 8, 3, …

## Check whether a given Binary Tree is Complete or not

Problem Statement   The problem “Check whether a given Binary Tree is Complete or not” states that you are given the root of a binary tree, check whether the tree is complete or not. A complete Binary Tree has all its levels filled except for the last level and the nodes …

## Count subarrays with equal number of 1’s and 0’s

Problem Statement   The problem “Count subarrays with equal number of 1’s and 0’s” states that you are given an array consisting of 0’s and 1’s only. The problem statement asks to find out the count of sub-arrays consisting equal no of 0’s ad 1’s. Example   arr[] = {0, 0, 1, …

## Count subarrays having total distinct elements same as original array

Problem Statement   “Count subarrays having total distinct elements same as original array” states that you are given an integer array. The problem statement asks to find out the total number of sub-arrays that contain all distinct elements as present in an original array. Example   arr[] = {2, 1, 3, 2, …

## Find the smallest positive integer value that cannot be represented as sum of any subset of a given array

Problem Statement   You are given a sorted array of integers. We need to find the smallest positive integer value that cannot be represented as sum of any subset of a given array. Example   arr[] = {1,4,7,8,10} 2 Explanation: Because there is not any sub-array that can represent 2 as a …

## Printing brackets in Matrix Chain Multiplication Problem

Problem Statement   We need to find the order of multiplication of matrices such that the number of operations involved in the multiplication of all the matrices is minimized. Then we need to print this order i.e. printing brackets in matrix chain multiplication problem. Consider you have 3 matrices A, B, …

## Find Three Element From Different Three Arrays Such That a + b + c = sum

Three Sum is a problem loved by interviewers. It is a problem I was personally asked during the Amazon interview. So, without wasting any more time let us get to the problem. An array that has both positive and negative numbers. Three numbers that sum up to zero/can be modified, …

## Decode Ways

In Decode Ways problem we have given a non-empty string containing only digits, determine the total number of ways to decode it using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Example   S = “123” Number of ways to decode this string is 3 If we …