← ALL NOTES
Array

3867. Sum of GCD of Formed Pairs

Given an integer array nums of length n. Build prefixGcd: for each index i, let mx_i = max(nums[0..i]), then prefixGcd[i] = gcd(nums[i], mx_i). Then sort prefixGcd non-decreasing and greedily form…

Loading…