Skip to main content

Practice · 2 of 5

Count Inversions-lite

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Two sorted arrays A (n) and B (m). Count pairs (i, j) with A[i] > B[j]. **Input:** Line 1: n m (1 <= n, m <= 200000). Line 2: n sorted ints. Line 3: m sorted ints (|values| <= 10^9). **Output:** One integer — the count (fits in 64 bits). **Example:** 3 2 / 1 3 5 / 2 4 -> 3 (3>2, 5>2, 5>4).

Back to lesson: Practice: Two Pointers Problem Set