Counting complement pairs

In the array [2, 4, 3, 5, 6, 4, 1, 7], how many unordered pairs of distinct positions (i,j)(i, j) with i<ji < j have array[i]+array[j]=8\text{array}[i] + \text{array}[j] = 8?

Show hints (2)+
  1. For each element, count how many earlier elements equal its complement 8x8-x.
  2. Watch the two 4s: they form a valid pair since they sit at different positions.

Answer

Reveal answer →

4

Want the full step-by-step worked solution? It's part of Premium - along with a worked solution for every question in the bank.

Asked at: Probability & Market-Making, Data-Driven Research

Related questions