Sunidhi Bansal has Published 1100 Articles

Count number of pairs (i, j) such that arr[i] * arr[j] > arr[i] + arr[j] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 12:03:46

571 Views

We are given an array of n positive numbers.The goal is to count the ordered pairs (i,j) such that arr[i]*arr[j] > arr[i]+arr[j] and 0sum.Traverse array using two for loops for each element of the pair.Outer Loop from 0

Count number of ordered pairs with Even and Odd Sums in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 12:01:45

245 Views

We are given an array of n positive numbers.The goal is to count the ordered pairs (arr[x], arr[y]) with the sum of arr[x] and arr[y] is even or odd. Pair ( arr[i], arr[j] ) and ( arr[j], arr[i] are counted as separate.We will traverse the array using two for loops ... Read More

Count number of ordered pairs with Even and Odd Product in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:59:47

132 Views

We are given an array of n positive numbers.The goal is to count the ordered pairs (arr[x], arr[y]) with the product of arr[x] and arr[y] is even or odd. Pair ( arr[i], arr[j] ) and ( arr[j], arr[i] are counted as separate.We will traverse the array using two for loops ... Read More

Count numbers with same first and last digits in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:57:28

352 Views

We are given an interval [first, last]. The goal is to find the count of numbers that have the same first and last digit within this interval. For example, 232 has the same first and last digit as 2.We will do this by traversing from i=first to i=last. For each ... Read More

Count the number of objects using Static member function in C++ Program

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:55:41

935 Views

The goal here is to count the number of objects of a class that are being created using a static member function.A static data member is shared by all objects of the class commonly. If no value is given, a static data member is always initialized with 0.A static member ... Read More

Count the number of operations required to reduce the given number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:53:16

198 Views

We are given with a positive integer K and an array Ops[] which contains integers. The goal is to find the number of operations required to reduce K such that it becomes less than 0. Operations are −First operation is K + Ops[0], first element added to KAfter 1. Add ... Read More

Count the number of pairs that have column sum greater than row sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:51:02

113 Views

We are given a matrix of size NXN. The goal is to find the count of all valid pairs of indexes (i, j) such that the sum elements of column j is greater than the sum of elements of row i.We will do this by traversing the matrix and calculate ... Read More

Count the number of pairs (i, j) such that either arr[i] is divisible by arr[j] or arr[j] is divisible by arr[i] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:49:03

893 Views

We are given with an array arr[] of N elements. The goal is to find the count of all valid pairs of indexes (i, j) such that either arr[i] is divisible by arr[j] or arr[j] is divisible by arr[i] and i!=j.We will do this by traversing the array arr[] using ... Read More

Count the number of possible triangles in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:47:14

609 Views

We are given an array which contains the length of sides of triangles. The goal is to find the number of possible triangles that can be made by taking any three sides from that array.We will do this by checking if the sum of any two is always > third ... Read More

Count the numbers < N which have equal number of divisors as K in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Aug-2020 11:45:21

122 Views

We are given two numbers N and K. The goal is to find the count of numbers between 1 and N that have divisors equal to the divisors of K in range [1, N].We will first count the divisors of K in range [1, N] and store in variable count.Now ... Read More

Advertisements