Search
⌘K

Leetcode 2426. Number of Pairs Satisfying Inequality

Transform to A[i] = nums1[i] - nums2[i] and count pairs i < j with A[i] <= A[j] + diff (equivalently A[i] - A[j] <= diff). This is a classic counting-within-bound problem for which divide-and-conquer (merge-sort counting) or a Fenwick tree with coordinate compression yields an O(n log n) solution.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.