Sunidhi Bansal has Published 1100 Articles

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

Sunidhi Bansal

Sunidhi Bansal

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

125 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

1K+ 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 Triplets such that one of the numbers can be written as sum of the other two in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 16-Sep-2020 10:02:31

1K+ Views

We are given an array Arr[] of integers with length n. The goal is to find the number of triplets (Arr[i], Arr[j], Arr[k]) such that the sum of any two numbers is equal to the third number.a+b=c, where a, b, c are elements of Arr[] with indexes i, j, k ... 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

429 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

100 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

Count number of sub-sequences with GCD 1 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:56:01

252 Views

We are given an array of integer elements and the task is to find the sub-sequences from the given array which are having GCD as 1. GCD is the greatest common divisor of two or more integers that divides the given numbers entirely and greatest amongst all.Input − int arr[] ... Read More

Count number of occurrences (or frequency) in a sorted array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:51:01

2K+ Views

We are given a sorted array of integer type elements and the number let’s say, num and the task is to calculate the count of the number of times the given element num is appearing in an array.Input − int arr[] = {1, 1, 1, 2, 3, 4}, num = ... Read More

Count rows/columns with sum equals to diagonal sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:43:47

112 Views

We are given a matrix which is a 2-D array having rows and columns and the task is to calculate the count of sum of all the rows and columns such that it is equal to the sum of either principal or secondary matrix.Input −int arr[row][col] = {    { ... Read More

Maximum circular subarray sum in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:38:09

253 Views

We are given an array and the task is to form the subarrays such that the sum of subarrays in a circular fashion will result in a maximum value.Input − int arr[] = {1, 2, 8, 4, 3, 0, 7}Output − Maximum circular subarray sum is − 22Explanation − we ... Read More

Count smaller values whose XOR with x is greater than x in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 31-Aug-2020 11:33:41

106 Views

We are given an integer number let’s say, x and the task are to count the smaller numbers less than x whose XOR with x will result in a value greater than the XOR value.The truth table for XOR operation is given belowABA XOR B000101011110Input − int x = 11Output ... Read More

Advertisements