Skip to content

Practice Maximum Element-Sum of a Complete Subset of Indices

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2862
LeetCode Problem

Maximum Element-Sum of a Complete Subset of Indices

Problem Statement

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.

Source: Maximum Element-Sum of a Complete Subset of Indices on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [8,7,3,5,7,2,4,9]
Output
16

# Example 2

Input
nums = [8,10,3,8,1,13,7,9,4]
Output
20

Constraints

1 <= n == nums.length <= 10^4
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Maximum Element-Sum of a Complete Subset of Indices.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.