Count of distinct pair sum between two 1 to N value Arrays Given a positive integer N such that there exists two arrays a[] and b[] each containing values {1, 2, 3, .., N}, the task is to find the count of all pairs (a[i], b[j]) such that a[i] + b[j] is unique among all the pairs i.e. if two pairs have equal sum then only one will be counted in the result.E
6 min read
Count pairs such that difference between them and indices are different Given an array arr[] of size N, the task is to count all pair of indices (i, j) such that i < j and j - i != arr[j] - arr[i]. Examples: Input: arr[] = {4, 1, 3, 3}Output: 5Explanation:The pair (0, 1) is a valid pair since 1 - 0 != 1 - 4.The pair (0, 2) is a valid pair since 2 - 0 != 3 - 4, 2 != -
7 min read
Number of pairs in an array such that product is greater than sum Given a array a[] of non-negative integers. Count the number of pairs (i, j) in the array such that a[i] + a[j] < a[i]*a[j]. (the pair (i, j) and (j, i) are considered same and i should not be equal to j) Examples: Input : a[] = {3, 4, 5} Output : 3 Pairs are (3, 4) , (4, 5) and (3,5) Input : a[]
8 min read
Count of unique pairs (arr[i], arr[j]) such that i < j Given an array arr[], the task is to print the count of unique pairs (arr[i], arr[j]) such that i < j. Examples: Input: arr[] = {1, 2, 1, 4, 5, 2} Output: 11 The possible pairs are (1, 2), (1, 1), (1, 4), (1, 5), (2, 1), (2, 4), (2, 5), (2, 2), (4, 5), (4, 2), (5, 2) Input: arr[] = {1, 2, 3, 4} O
11 min read