values.
The score of an array is the greatest common divisor (GCD) of all its elements multiplied by their least common multiple (LCM). For a single number both the GCD and the LCM equal the number itself, and the score of an empty array is 0.
You may remove at most one element from the array. Return the highest score you can get.values=[3, 6, 12] → 72
Keeping everything: GCD 3, LCM 12, score 36. Dropping 3 makes the GCD 6 and the LCM 12, for a score of 72, which is the best.
values=[2, 3, 4] → 12
Keeping everything: GCD 1, LCM 12, score 12. Dropping 2 gives 1 · 12 = 12, dropping 3 gives 2 · 4 = 8, dropping 4 gives 1 · 6 = 6. The answer is 12.
values=[7] → 49
For a single number both the GCD and the LCM are 7, so the score is 49. Dropping it leaves an empty array with score 0.
values=[3, 6, 12]
72
Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.