Data Structures & AlgorithmsModerateCodeforces Div2 C · TCS NQT

How many unordered pairs of different positions in [3, 8, 2, 9, 5, 4] have a product at most 24?

  1. A. 10
  2. B. 14
  3. C. 9
  4. D. 8

Correct answer: C. 9

Sort the array; for each i, the valid j form a prefix (values increase), so a two-pointer or binary search over the sorted array counts them in O(n log n). Using a fixed multiplication threshold per pair without sorting is slower and easy to get wrong at the boundary.

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

Exams that ask this topic