Easy to understand solution using TreeMap.
Complexity

Time complexity:
O(m × n+ mlogm)
(where O(m×n) is from the outer loop and the inner loop,
O(mlog⁡m) is from inserting into the TreeMap and iterating
# Complexity
- Time complexity:
**O(m × n+ mlogm)**
*(where O(m×n) is from the outer loop and the inner loop,
O(mlog⁡m) is from inserting into the TreeMap and iterating over it)*

- Space complexity:
**O(m)**

# Code
```java []
class Solution {
    public int maxDivScore(int[] nums, int[] divisors) {
        TreeMap<Integer, Integer> scoreMap = new TreeMap<>();
        int maxScore = -1;
        int n = nums.length;
        int m = divisors.length;

        for (int i = 0; i < m; i++) {
            int count = 0;
            for (int j = 0; j < n; j++) {
                if (nums[j] % divisors[i] == 0) {
                    count++;
                }
            }
            scoreMap.put(divisors[i], count);
            maxScore = Math.max(maxScore, count);
        }

        for (Map.Entry<Integer, Integer> entry : scoreMap.entrySet()) {
            if (entry.getValue() == maxScore) {
                return entry.getKey();
            }
        }
        return -1;
    }
}
```
['Java']