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 …

Read moreLargest subarray with equal number of 0s and 1s

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 …

Read moreNon-overlapping sum of two sets

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 …

Read moreRange sum queries without updates

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 …

Read moreThree way partitioning of an array around a given range

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}, …

Read morePalindrome Substring Queries

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 …

Read moreCheck if each internal node of a BST has exactly one child

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 …

Read moreElements to be added so that all elements of a range are present in array