Sunidhi Bansal has Published 1085 Articles

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

119 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

253 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

503 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

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

490 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

293 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

542 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

383 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

143 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

336 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

712 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

Advertisements