Tap here to switch tabs
Problem
Submissions

Problem: Number of Squareful Arrays

Number of Squareful Arrays asks you to count unique permutations of an integer array where every pair of adjacent values sums to a perfect square.

Statement

An array is defined as squareful if the sum of every pair of adjacent elements is a perfect square.

Given an integer array nums, return the total number of unique permutations of nums that are squareful.

Two permutations perm1 and perm2 are considered distinct if there exists at least one index i such that perm1[i] != perm2[i].

Constraints:

  • 1≤1 \leq nums.length ≤12\leq 12

  • 0≤0 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Squareful Arrays

Number of Squareful Arrays asks you to count unique permutations of an integer array where every pair of adjacent values sums to a perfect square.

Statement

An array is defined as squareful if the sum of every pair of adjacent elements is a perfect square.

Given an integer array nums, return the total number of unique permutations of nums that are squareful.

Two permutations perm1 and perm2 are considered distinct if there exists at least one index i such that perm1[i] != perm2[i].

Constraints:

  • 1≤1 \leq nums.length ≤12\leq 12

  • 0≤0 \leq nums[i] ≤109\leq 10^9