Find the Length of the Longest Common Prefix

Given two integer arrays arr1 and arr2, implement solve(arr1, arr2) returning the length of the longest common prefix of the factors. For each value x, its factor prefix is the list of all positive divisors of x in increasing order. For a pair a in arr1 and b in arr2, the common prefix length is the longest initial segment where the two divisor lists match entry by entry. Return the maximum length over all pairs. Every integer contributes 1 as its first divisor, so the answer is at least 1 when both arrays are non-empty.

Examples
Input: ["flower","flow","flight"]
Output: 2
Hints

Find the Length of the Longest Common Prefix

Given two integer arrays `arr1` and `arr2`, implement `solve(arr1, arr2)` returning the length of the longest common prefix of the factors. For each value `x`, its factor prefix is the list of all positive divisors of `x` in increasing order. For a pair `a` in `arr1` and `b` in `arr2`, the common prefix length is the longest initial segment where the two divisor lists match entry by entry. Return the maximum length over all pairs. Every integer contributes `1` as its first divisor, so the answer is at least `1` when both arrays are non-empty.