Sunidhi Bansal has Published 1100 Articles

Count of values of x <= n for which (n XOR x) = (n – x) in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:09:07

279 Views

We are given a number n as input. The goal is to find values x such that condition (n xor x)=(nx) holds. Also x lies in range [0,n].Let us understand with examplesInput − n=10Output − Count of values of x

Count of unique pairs (arr[i], arr[j]) such that i < j in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:07:12

679 Views

We are given an array containing integer elements. The goal is to find unique pairs of elements of array such that pairs of type (arr[i], arr[j]) have indexes such that iLet us understand with examplesInput − arr[] = {1, 2, 3};Output − Count of unique pairs (arr[i], arr[j]) such that ... Read More

Count of subsequences having maximum distinct elements in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:03:07

228 Views

We are given an array arr[] containing integers only. The goal is to find the number of subsequences of arr[] such that they have maximum number distinct elements. If the array is [ 4, 1, 2, 3, 4 ] then two subsequences will be [ 4, 1, 2, 3 ] ... Read More

Count operations of the given type required to reduce N to 0 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 12:00:00

656 Views

We are given a positive integer N. The goal is to find the number of operations required to reduce N to 0. Operation applied is N=N-P where P is the smallest prime divisor of P.Let us understand with examplesInput − N=17Output − Count of operations of the given type required ... Read More

Count pairs from two BSTs whose sum is equal to a given value x in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:58:03

189 Views

We are given two binary search trees as input and a variable x. The goal is to find pairs of nodes from each tree such that the sum of value of nodes is equal to x. Take node 1 from BST_1 and node 2 from BST_2 and add data part ... Read More

Count pairs from two arrays whose modulo operation yields K in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:54:32

145 Views

We are given two arrays containing positive numbers and a value K. The goal is to find unique pairs of elements of arrays such that pairs of type (A, B) has A%B=K or B%A=K and A belongs to the first array and B belongs to the second array.Let us understand ... Read More

Count pairs from two sorted arrays whose sum is equal to a given value x in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:50:09

358 Views

We are given two arrays containing positive numbers and a value x. The goal is to find pairs of elements of arrays such that pairs of type (A, B) has A+B=x and A belongs to the first array and B belongs to the second array.Let us understand with examplesInput − ... Read More

Count pairs in an array such that at least one element is prime in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:39:04

126 Views

We are given an array of positive integers. The goal is to find the count of distinct pairs of elements of an array that have at-least one prime member. If the array is [1, 2, 3, 4] then pairs would be (1, 2), (1, 3), (2, 3), (2, 4) and ... Read More

Count pairs in an array such that LCM(arr[i], arr[j]) > min(arr[i],arr[j]) in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:35:27

172 Views

We are given an array of positive integers. The goal is to find the count of pairs of elements of arr[] such that condition LCM( arr[i], arr[j] ) > minimum of ( arr[i], arr[j] ). That is, the lowest common multiple of elements in a pair is greater than the ... Read More

Count pairs in an array that hold i*arr[i] > j*arr[j] in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Dec-2020 11:34:05

136 Views

We are given an array of numbers. The goal is to find the pair of elements of array such that they hold the conditionIf (i*arr[i] > j*arr[j]) then (arr[i], arr[j]) is a valid pair.If the array is [ 5, 4, 3, 2, 1 ] then pairs will be [3, 1] ... Read More

Advertisements