JuniorArray
Find the Maximum Divisibility Score
You are given two integer arrays nums and divisors.
The divisibility score of divisors[i] is the number of indices j such that nums[j] is divisible by divisors[i].
Return the integer divisors[i] with the maximum divisibility score. If multiple integers have the maximum score, return the smallest one.
Example 1
Input
nums = [2,9,15,50], divisors = [5,3,7,2]Output
2Divisors 5, 3, and 2 all have divisibility score 2, so the smallest of them, 2, is returned.
Example 2
Input
nums = [4,7,9,3,9], divisors = [5,2,3]Output
3Divisor 3 has the highest divisibility score of 3 because 9, 3, and 9 are divisible by 3.
Constraints
- 1 <= nums.length, divisors.length <= 1000
- 1 <= nums[i], divisors[i] <= 10^9