Find number of pairs in an array such that their XOR is 0

The problem “Find number of pairs in an array such that their XOR is 0” state that supposes, we have given an array of integers. The problem statement asks to find out the number of pairs present in an array, which has the pair Ai XOR Aj = 0. Note: …

Read moreFind number of pairs in an array such that their XOR is 0

Find subarray with given sum (Handles Negative Numbers)

The problem “Find subarray with given sum (Handles Negative Numbers)” states that you are given an integer array, containing negative integers as well and a number called “sum”. The problem statement asks to print the sub-array, which sums up to a given number called “sum”.  If more than one sub-array …

Read moreFind subarray with given sum (Handles Negative Numbers)

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

Read moreSum of minimum and maximum elements of all subarrays of size k

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

Read moreCount subarrays with equal number of 1’s and 0’s

Maximum Depth Of Binary Tree

Problem Statement “Maximum depth of binary tree” problem states that you are given a binary tree data structure. Print the maximum depth of the given binary tree. Example Input 2 Explanation: Maximum depth for the given tree is 2. Because there is only a single element below the root (i.e. …

Read moreMaximum Depth Of Binary Tree

Find the minimum distance between two numbers

Problem Statement You have given an array and two numbers called x and y. The problem “Find the minimum distance between two numbers” asks to find out the minimum possible distance between them. The array given can have common elements. You can assume that both x and y are different. …

Read moreFind the minimum distance between two numbers

Find the Only Repetitive Element Between 1 to N-1

In finding the only repetitive element between 1 to N-1 problem we have given an array of random integers within a range from 1 to n-1. There will be one number that is repeated. Your task is to find that number. Example Input [2,3,4,5,2,1]A Output 2 Explanation 2 is the …

Read moreFind the Only Repetitive Element Between 1 to N-1