Sunidhi Bansal has Published 1100 Articles

Count number of triplets with product equal to given number with duplicates allowed in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 09:01:41

306 Views

We are given with an array of numbers Arr[]. The goal is to count the number of triplets whose product is equal to the given number p. There can be more than one triplet with the same values but different elements. For example, (1, 2, 3) and (3, 1, 2) ... Read More

Count number of triplets in an array having sum in the range [a,b] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:58:32

214 Views

We are given an array of integers, Arr[] and two variables a and b to define a range [a, b]. The goal is to find the number of triplets whose sum lies in between this range [a, b].We will do this by using three for loops. Increment count if arr[i]+arr[j]+arr[k]>=a ... Read More

Count number of triplets (a, b, c) such that a^2 + b^2 = c^2 and 1<=a<=b<=c<= n in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:55:45

377 Views

We are given an integer n. The goal is to find triplets ( set of 3 numbers ) that satisfy the conditions −a2+b2=c21

Count number of step required to reduce N to 1 by following certain rule in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:51:32

298 Views

We are given a number N. The goal is to count the number of steps required to reduce the number to 1 by following rules −If the number is power of 2, reduce it to its half.Else reduce it to the N-(nearest power of 2 which is less than N).For ... Read More

Count number of solutions of x^2 = 1 (mod p) in given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:48:06

82 Views

We are given with integers x and p. The goal is to find the number of solutions of the equation −x2=1 ( mod p ) such that x lies in range [1, N].We will do this by traversing from 1 to N and take each number as x check if ... Read More

Count number of right triangles possible with a given perimeter in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:44:24

221 Views

We are given a perimeter P of a triangle. Perimeter is the sum of all sides of the triangle. The goal is to find the number of right triangles that can be made which have the same perimeter.If the sides of the triangle are a, b and c. Then a ... Read More

Count number of squares in a rectangle in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:41:48

583 Views

We are given with a rectangle of length L and breadth B, such that L>=B. The goal is to find the number of squares that a rectangle of size LXB can accommodate.Above figure shows a rectangle of size 3 X 2. It has 2, 2X2 squares and 6, 1X1 squares ... Read More

Count number of smallest elements in given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:37:30

208 Views

We are given an array of integers of size N. Variables L and R define a range between 1 and N. The goal is to find the number of smallest elements that lie in range L and R such that L>=1 and R

Count number of primes in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:33:54

9K+ Views

We are given with an array of numbers. The goal is to find the count of prime numbers in that array.A prime number is the one which is divisible by 1 and the number itself. It has only two factors. We will check if the number is prime starting from ... Read More

Maximize profit when divisibility by two numbers have associated profits in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 08:30:31

69 Views

We are given with five integers N, A, B, X and Y. The goal is to maximize the profit by checking that between numbers in range [ 1 to N ] , ifA number is divisible by A, then profit increases by X.A number is divisible by B then profit ... Read More

Advertisements