How do you count the number of pairs?
= n(n-1) / 2 which is our formula for the number of pairs needed in at least n statements.
How to count pairs in JavaScript?
Count pairs in an array that hold i+j= arr[i]+arr[j] Given an array of integers arr[], the task is to count all the pairs (arr[i], arr[j]) such that i + j = arr[i] + arr[j] for all 0 ≤ i < j < n. Note: Pairs (x, y) and (y, x) are considered a single pair.