Back to problems

Solve pair-counting and account-merging problems

Algorithm · ByteDance · Hard

Given two arrays of non-negative integers A and B and an integer threshold T, for each value a in A, determine how many values b in B satisfy: $$a \times b \ge T$$ Return an integer array ans with the same length as A, where ans[i] corresponds to A[i]. Example 1: Explanation: For 5, the valid values are 3 and 4; for 7, the valid values are 2, 3, and 4; for 2, no value in B produces a product of at least 12. Example 2: Explanation: 5 pairs with the two occurrences of 6; 0 has…

Checking your access…