Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

On a 3 by 3 grid, how many unordered pairs of distinct cells share a row or a column?

  1. A. 19
  2. B. 36
  3. C. 30
  4. D. 18

Correct answer: D. 18

Each of the 3 rows has C(3,2) = 3 pairs, giving 9, and each of the 3 columns gives another 9, for 18 in total. The count of all pairs (36) is the trap.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic