FastPrepFastPrep
Problem Brief

Find Pair with Maximum GCD

OA
See Tiktok online assessment and hiring insights

The question was phrased with verbosity leading to "find the pair with maximum GCD in an array :)"

1Example 1

Input
arr = [1, 2, 3, 4, 8, 9]
Output
4
Explanation
The pair with the maximum GCD in the array [1, 2, 3, 4, 8, 9] is (4, 8), which has a GCD of 4.

2Example 2

Input
arr = [1, 2, 3, 5]
Output
1
Explanation
The pair with the maximum GCD in the array [1, 2, 3, 5] is (3, 5), which has a GCD of 1.

Constraints

Limits and guarantees your solution can rely on.

🐈
public int findPairWithMaximumGCD(int[] arr) {
  // write your code here
}
Input

arr

[1, 2, 3, 4, 8, 9]

Output

4

Sign in to submit your solution.