Maximum possible difference of two subsets of an array

Suppose, we have an integer array. The problem statement “Maximum possible difference of two subsets of an array” asks to find out the maximum possible difference between the two subsets of an array. Conditions to be followed: An array can contain repeating elements, but the highest frequency of an element …

Read moreMaximum possible difference of two subsets of an array

How to check if two given sets are disjoint?

The problem “How to check if two given sets are disjoint?” states that suppose you are given two sets in the form of array say set1[] and set2[]. Your task is to find out whether the two sets are Disjoint Sets or not. Example inputSet1[] = {1, 15, 8, 9, …

Read moreHow to check if two given sets are disjoint?

Print modified array after executing the commands of addition and subtraction

You are given an array of size n, initially all the values in the array will be 0, and the queries. Each query contains the four values, type of the query T, left point of the range, the right point of a range and a number k, you have to …

Read morePrint modified array after executing the commands of addition and subtraction

Number of indexes with equal elements in given range

You are given an integer array, q queries, and a range as left and right. The “Number of indexes with equal elements in given range” says to find out the total number of count of integers in such a way that left <= i < right, such that Ai = Aj+1. …

Read moreNumber of indexes with equal elements in given range

Number of elements less than or equal to a given number in a given subarray

Problem Statement The problem “Number of elements less than or equal to a given number in a given subarray” states that you are given an integer array and q number of queries. There will be two types of queries à queryUpdate(i, v): There will be two integers i and v, …

Read moreNumber of elements less than or equal to a given number in a given subarray

Clone a Binary Tree with Random Pointers

Problem Statement You are given a complete binary tree with some random pointers. Random pointers are referred to nodes which every node points to other than its left and right child. So, this also changes the standard structure of a node in a simple binary tree. Now the node of …

Read moreClone a Binary Tree with Random Pointers

Distinct adjacent elements in an array

Problem Statement Suppose we have an integer array. The problem “Distinct adjacent elements in an array” asks to determine if it is possible to get the array in which all the adjacent numbers are distinct or not by swapping up two adjacent or neighbour elements in an array if it …

Read moreDistinct adjacent elements in an array

Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’

Problem Statement The problem ” Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’ ” states that you have an “n” sized array containing integers. The numbers in the array are in a range of 0 to n-1. The problem statement asks to rearrange the array in …

Read moreRearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’