Sunidhi Bansal has Published 1085 Articles

Count numbers with difference between number and its digit sum greater than specific value in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:53:26

614 Views

We are provided two numbers N which defines a range [1, N] and D which is a difference.The goal is to find all the numbers in the range [1, N] such that the [ number - (sum of its digits) ] > D. We will do this by traversing numbers ... Read More

Count numbers in range that are divisible by all of its non-zero digits in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:50:25

232 Views

We are provided two numbers START and END to define a range of numbers.The goal is to find all the numbers in the range [START, END] that are divisible by all of its non-zero digits . We will do this by traversing numbers from START to END and for each ... Read More

Count numbers in range 1 to N which are divisible by X but not by Y in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:47:44

637 Views

We are provided a number N. The goal is to find the numbers that are divisible by X and not by Y and are in the range [1, N].Let’s understand with examples.Input N=20 X=5 Y=20Output Numbers from 1 to N divisible by X not Y: 2Explanation Only 5 and 15 are divisible by ... Read More

Count numbers in a range that are divisible by all array elements in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:45:19

640 Views

We are provided two numbers START and END to define a range of numbers. And also an array of positive numbers Arr[]. The goal is to find all the numbers that are divisible by all elements of Arr[] and are in the range [START, END] .Method 1 ( Naive Approach ... Read More

Count numbers having 0 as a digit in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:41:17

2K+ Views

We are provided a number N. The goal is to find the numbers that have 0 as digit and are in the range [1, N].We will do this by traversing numbers from 10 to N ( no need to check from 1 to 9 ) and for each number we ... Read More

Count numbers from range whose prime factors are only 2 and 3 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:39:15

759 Views

We are provided two numbers START and END to define a range of numbers. The goal is to find the numbers that have only 2 and 3 as their prime factors and are in the range [START, END].We will do this by traversing numbers from START to END and for ... Read More

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

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Oct-2020 04:36:35

246 Views

We are given an array Arr[] of integers with length n and a number M. The array is only containing positive integers. The goal is to count the triplets of elements of Arr[] which have product equal to M.We will do this by using three for loops. Increment count if ... Read More

Count the numbers divisible by ‘M’ in a given range in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 16-Sep-2020 10:03:55

2K+ Views

We are given three numbers A, B and M. A and B define the range [A, B] of numbers.The goal is to count numbers between A and B that are divisible by M.We will start from i=A till first multiple of M. Increment count if i%M=0. Now increment i till ... Read More

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

Sunidhi Bansal

Sunidhi Bansal

Updated on 16-Sep-2020 10:00:45

597 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

Count pairs with bitwise OR less than Max in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 14:09:30

155 Views

We are given an integer array and the task is to count the total number of pairs that can be formed using the given array values such that the OR operation on the pairs will result in the value less than MAX value in the given pair.The truth table for ... Read More

Advertisements