Sunidhi Bansal has Published 1085 Articles

Count passing car pairs in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:26:13

332 Views

We are given an array of length N containing 0’s and 1’s only. The value 1 represents a car going towards west direction and value 0 represents a car going towards east direction.We count passing cars as 1 if a pair of car A and car B is such that 0

Count pairs of natural numbers with GCD equal to given number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:25:00

1K+ Views

We gave three input variables as ‘start’, ‘end’ and ‘number’. The goal is to find pairs of numbers between start and end that have GCD value equal to ‘number’. For example GCD(A, B)=number and both A, B are in range [start, end].Let us understand with examples.Input − start=5 end=20 number=8Output ... Read More

Count pairs with average present in the same array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:20:18

303 Views

We are given an array of integers such that each element of the array is in the range [- 1000, 1000]. The goal is to find pairs of elements of the array such that their average is also present in that array. If array is arr[]= [1, 2, 3, 4]. ... Read More

Count pairs of numbers from 1 to N with Product divisible by their Sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:18:23

253 Views

We are given a number N. The goal is to find the pairs of numbers from 1 to N such that the product of pairs is equal to the sum of pairs.Let us understand with examples.Input − N=11Output − Count of pairs of no. from 1 to N with Product ... Read More

Count the number of carry operations required to add two numbers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:16:24

2K+ Views

We are given two numbers num_1 and num_2. The goal is to count the number of carry operations required if the numbers are added. If numbers are 123 and 157 then carry operations will be 1. (7+3=10, 1+2+5=8, 1+1=2 ).Let us understand with examplesInput − num_1=432 num_2=638Output − Count of ... Read More

Count positive integers with 0 as a digit and maximum ‘d' digits in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:06:56

133 Views

We are given a number d which represents the number of digits. The goal is to find the count of positive integers with 0 as a digit and have maximum d digits. Count all 1 digit, 2 digit, 3 digit….d digit positive numbers containing at least one 0.We will first ... Read More

Count the number of rhombi possible inside a rectangle of given size in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:04:39

215 Views

We are given a rectangle with dimensions as height X width. The rectangle is represented on a 2D coordinate system with the left-lower corner at point (0, 0). So the goal is to count the number of rhombi possible inside this rectangle such that all these conditions are met −The ... Read More

Count Possible Decodings of a given Digit Sequence in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 13:02:52

288 Views

We are given a string representing a digit sequence. Each digit is decoded from 1 to 26 as English Alphabet. 1 is ‘A’, 2 is ‘B’ and so on till 26 as ‘Z’. The goal is to find the count of all possible decodings out of a given digit sequence. ... Read More

Count rotations divisible by 8 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:57:52

334 Views

We are given a large number. The goal is to count the rotations of num that are divisible by 8.As the rotations can not be done again and again. We will use the divisible by 8 property. If the last three digits are divisible by 8then the number is divisible ... Read More

Count rotations divisible by 4 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 01-Dec-2020 12:55:38

690 Views

We are given a large number. The goal is to count the rotations of num that are divisible by 4.As the rotations can not be done again and again. We will use the divisible by 4 property. If the last two digits are divisible by 4 then the number is ... Read More

Advertisements