#2862
Maximum Element-Sum of a Complete Subset of Indices
hard · 42.8% accepted · 233 likes · top 24%
array · math · number theory
Description
You are given a 1-indexed array nums. Your task is to select a complete subset from nums where every pair of selected indices multiplied is a perfect square,. i. e. if you select ai and aj, i * j must be a perfect square.
Return the sum of the complete subset with the maximum sum.
Solution