## Given a binary tree, how do you remove all the half nodes?

The problem “Given a binary tree, how do you remove all the half nodes?” states that you are given a binary tree. Now you need to remove the half nodes. A half node is defined as a node in the tree that has only a single child. Either it is …

## Find missing elements of a range

The problem Find missing elements of a range” states that you are given an array of distinct elements within a particular range and a range given as low and high. Find all the missing elements within a range which is not present in an array. The output should be in …

## Largest subarray with equal number of 0s and 1s

You are given an array of integers. The integers are only 0 and 1 in the input array. The problem statement asks to find out the largest sub-array that can have equal count of 0s and 1s. Example   arr[]={0,1,0,1,0,1,1,1} 0 to 5 (total 6 elements) Explanation From the array position …

## Non-overlapping sum of two sets

Problem Statement   The problem “Non-overlapping sum of two sets” states that you are given two arrays as input values as arrA[] and arrB[] of the same size n. Also, both of the arrays have distinct elements individually and some common elements. Your task is to find out the total sum …

## Range sum queries without updates

Problem Statement   The problem “Range sum queries without updates” states that you have an array of integers and a range. The problem statement asks to find out the sum of all the elements within the given range. Example   arr[]={10, 9, 8, 7, 6} Query: {(0, 4), (1, 3)} 40 24 …

## Three way partitioning of an array around a given range

Problem Statement   You are given an array of integers and a range of lowValue and highValue. The problem “Three way partitioning of an array around a given range” asks to partition the array such that array will be divided into three parts. The partitions of the arrays will be: Elements …

## Find a sorted subsequence of size 3 in linear time

Problem Statement   The problem “Find a sorted subsequence of size 3 in linear time” states that you have an integer array. The problem statement asks to find out the three numbers in such a way that array[i] < array [k] < array[k], and i < j < k. Example   arr[] …

## Palindrome Substring Queries

Problem Statement   The problem “Palindrome Substring Queries” states that you are given a String and some queries. With those queries, you have to determine if the formed substring from that query is a palindrome or not. Example   String str = “aaabbabbaaa” Queries q[] = { {2, 3}, {2, 8},{5, 7}, …

## Check if each internal node of a BST has exactly one child

Problem Statement   “Check if each internal node of a BST has exactly one child” problem states that you are given a preorder traversal of a binary search tree. And you need to find if all the non-leaf nodes contain only a single child. Here we also consider that all the …

## Elements to be added so that all elements of a range are present in array

Problem Statement   “Elements to be added so that all elements of a range are present in array” states that you are given an array of integers. The problem statement asks to find out the count of elements to be added in an array so that all elements lie in the …