Count of index pairs with equal elements in an array

Suppose, we have given an integer array. The problem “Count of index pairs with equal elements in an array” asks to find out the no of pair of indices (i,j) in such a way that arr[i]=arr[j] and i is not equal to j. Example arr[] = {2,3,1,2,3,1,4} 3 Explanation Pairs …

Read moreCount of index pairs with equal elements in an array

Longest subarray not having more than K distinct elements

The problem “Longest subarray not having more than K distinct elements” states that suppose you have an array of integers, the problem statement asks to find out the longest sub-array that having not greater than k different elements. Example arr[] = {4, 3, 5, 2, 1, 2, 0, 4, 5} …

Read moreLongest subarray not having more than K distinct elements

Minimum operation to make all elements equal in array

The problem “Minimum operation to make all elements equal in array” states that you are given an array with some integers in it. You have to find out the minimum operations that can be done to make an array equal. Example [ 1,3,2,4,1] 3 Explanation Either 3 subtractions can be …

Read moreMinimum operation to make all elements equal in array

Difference between highest and least frequencies in an array

The problem “Difference between highest and least frequencies in an array” states that suppose that you have an integer array. The problem statement asks to find out the maximum difference between the highest frequency and lowest frequency of two distinct numbers in an array. Example arr[] = {1, 2, 3, …

Read moreDifference between highest and least frequencies in an array

k-th missing element in increasing sequence which is not present in a given sequence

The problem “k-th missing element in increasing sequence which is not present in a given sequence” states that you are given two arrays. One of them is arranged in ascending order and another normal unsorted array with number k. Find the kth missing element which is not present in normal …

Read morek-th missing element in increasing sequence which is not present in a given sequence

Check if a given array contains duplicate elements within k distance from each other

The problem “Check if a given array contains duplicate elements within k distance from each other” states that we have to check for duplicates in given unordered array within the range of k. Here the value of k is smaller than the given array. Examples K = 3   arr[] = …

Read moreCheck if a given array contains duplicate elements within k distance from each other

Print n terms of Newman-Conway Sequence

Problem Statement The problem “Print n terms of Newman-Conway Sequence” states that you are given an integer “n”. Find the first n terms of Newman-Conway Sequence then print them. Example n = 6 1 1 2 2 3 4 Explanation All the terms which are printed follow the Newman-Conway Sequence …

Read morePrint n terms of Newman-Conway Sequence

Find all pairs (a, b) in an array such that a % b = k

Problem Statement The problem “Find all pairs (a, b) in an array such that a % b = k” states that you are given an array of integers and an integer value called k. The problem statement asks to find out the pair in such a way that that x …

Read moreFind all pairs (a, b) in an array such that a % b = k

Queries on XOR of greatest odd divisor of the range

Problem Statement The problem “Queries on XOR of greatest odd divisor of the range” states that you are given an array of integer and query q, each query consists of a range. The problem statement asks to find out the XOR of the greatest odd divisor within the given range …

Read moreQueries on XOR of greatest odd divisor of the range

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