Problem · Math
Find Pair with Maximum GCD
Learn this problemProblem statement
Given an integer array arr, choose two elements at distinct indices and return the maximum possible greatest common divisor (GCD) of the pair.
Function
findPairWithMaximumGCD(arr: int[]) → intExamples
Example 1
arr = [1, 2, 3, 4, 8, 9]return = 4The pair (4, 8) has GCD 4, which is the maximum possible.
Example 2
arr = [1, 2, 3, 5]return = 1The pair (3, 5) has GCD 1. Every pair in the array has GCD 1.
Constraints
arrcontains at least two elements.- Every element of
arris a positive 32-bit integer.
More Tiktok problems
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jul 2026
- Obstacle Placement QueriesOA · Seen Jul 2026
- Repeated Grouped Digit SumOA · Seen Jul 2026
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026