Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 42 of 81

Maximize number of continuous Automorphic numbers in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 386 Views

Given the task is to maximize the number of continuous Automorphic elements in a given array with N number of elements.An automorphic number is a number whose square ends with the same digits as the number itself. For example 5 is an automorphic number as 5*5 = 25 and 25 ends with 5.Let’s now understand what we have to do using an example −Input − arr[]={5, 3, 625, 6, 8, 1}Output − 2Explanation − Automorphic numbers present in the above array are 5, 625, 6 and 1 but the maximum continuous automorphic numbers are {625, 6} which makes the output ...

Read More

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

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 188 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

Read More

Count ways to form minimum product triplets in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 330 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

Read More

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

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 783 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 check if the square root of that sum is equal to the floor value of the square root. sqrt(Arr[i]+Arr[j])-floor( sqrt(Arr[i]+Arr[j] )==0.Let’s understand with examples.Input − Arr[]= { 4, 3, 2, 1, 2, 4 } N=6Output − Count of pairs with sum as perfect square − 2Explanation −Arr[1]+Arr[3]=4, sqrt(4)-floor(4)=0 4 is ...

Read More

Maximum number of dots after throwing a dice N times in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 238 Views

Given the task is to calculate the maximum number of dots that can be expected after throwing a dice N times having M faces.The first face of the dice contains 1 dot, the second face has 2 dots and so on. Likewise the M-th face contains M number of dots.The probability of appearance of each face becomes 1/M.Let’s now understand what we have to do using an example −Input − M=2, N=3Output − 1.875Explanation − The dice has 2 sides = {1, 2}If the dice is thrown 3 times then the sample space will be = MN = 23{(1, 1, ...

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 11-Mar-2026 476 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 check if the square root of that sum is equal to the floor value of the square root. sqrt(Arr[i]+Arr[j])-floor( sqrt(Arr[i]+Arr[j] )==0.Let’s understand with examples.Input − Arr[]= { 4, 3, 2, 1, 2, 4 } N=6Output − Count of pairs with sum as perfect square − 2Explanation −Arr[1]+Arr[3]=4, sqrt(4)-floor(4)=0 4 is ...

Read More

Count valid pairs in the array satisfying given conditions in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 684 Views

We are given with an array arr[] of N elements. The goal is to find the count of all valid pairs (Arr[i],Arr[j]) that follow certain conditions. Pairs Arr[i],Arr[j] invalid if −Arr[i]==Arr[j]Arr[i]+Arr[j] is eveni+j

Read More

Maximum number of groups of size 3 containing two type of items in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 282 Views

Given the task is to calculate the maximum number of groups of size 3 that can be formed when N number of items of type A and M number of items of type B are given.Also, each group should have at least one item of each type, that is either A or B.Let’s now understand what we have to do using an example −Input − N=3, M=5Input − 2ExplanationGroup 1: 1 item of type A and 2 items of type B Group 2: 1 item of type A and 2 items of type B In total, 2 items of type ...

Read More

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

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 415 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). And store as maxdiff. Then count all those pairs that have difference=maxdiff.Let’s understand with examples.Input − arr[]= { 1, 2, 3, 2, 4, 1, 5 }Output − No. of ways of choosing pair with maximum difference − 2Explanation −Here minimum no. is 1 and maximum number is 5, maximum difference ...

Read More

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

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 518 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]

Read More
Showing 411–420 of 809 articles
« Prev 1 40 41 42 43 44 81 Next »
Advertisements