Sunidhi Bansal has Published 1100 Articles

Counting cross lines in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:34:55

146 Views

We are given with an array of distinct elements that are unsorted. The goal is to find the cross lines after the array is sorted. Cross lines are counted as shown below −Arr[]={ 1, 2, 4, 3, 5 } There are 3 cross lines as shown belowArr[]= { 1, 2, ... Read More

Count total divisors of A or B in a given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:26:38

268 Views

We are given four integers L, R, A and B. The goal is to find the count of numbers in range [L, R] that fully divide either A or B or both.We will do this by traversing from L to R and for each number if number%A==0 or number%B==0 then ... Read More

Count the triplets such that A[i] < B[j] < C[k] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:22:43

310 Views

We are given with three arrays A[], B[] and C[]. The goal is to find all triplets of elements of these arrays such that A[i]

Count ways of choosing a pair with maximum difference in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:20:01

236 Views

We are given with an array of numbers Arr[]. The goal is to count the number of pairs whose difference is equal to the maximum difference of all possible pairs. Count pairs (i!=j) and arr[x]- arr[y] is maximum possible.We will do this by first finding the maximum difference where (i!=j). ... Read More

Count unordered pairs (i,j) such that product of a[i] and a[j] is power of two in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:35:10

305 Views

We are given with an array of N elements. The goal is to find the count of all pairs (Arr[i], Arr[j]) which have a sum which is a perfect square such that i!=j. That is Arr[i]+Arr[j] is a perfect square.We will do this by calculating the sum of pairs and ... Read More

Count of pairs in an array whose sum is a perfect square in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:22:33

517 Views

We are given with an array of N elements. The goal is to find the count of all pairs (Arr[i], Arr[j]) which have a sum which is a perfect square such that i!=j. That is Arr[i]+Arr[j] is a perfect square.We will do this by calculating the sum of pairs and ... Read More

Count ways to form minimum product triplets in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:19:36

132 Views

We are given with an array of numbers Arr[]. The goal is count the number of triplets whose product is equal to the smallest product of all possible triplets.Count triplets if (i

Counting numbers whose difference from reverse is a product of k in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:11:19

68 Views

We are given a range [l,r] and a number k. The goal is to find all the numbers between l and r (l

Counting pairs when a person can form pair with at most one in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:08:11

196 Views

We are given with N no. of participants in a coding competition. The goal is to find the no. of pairs that are possible when a person can pair with at most one other person. So a pair has at most 2 participants. The participants are allowed to take part ... Read More

Count of index pairs with equal elements in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:05:28

335 Views

We are given with an array of N elements. The goal is to find the index pairs (i, j) which have the same element value such that i!=j. i.e, Arr[i]=Arr[j] and i!=j. This is used to make pairs of gloves of equal size. Out of N gloves only paired gloves ... Read More

Advertisements