Practice Number of Squareful Arrays
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#996
LeetCode ProblemNumber of Squareful Arrays
Problem Statement
An array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutations of nums that are squareful. Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].
Source: Number of Squareful Arrays on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,17,8]
Output
2
# Example 2
Input
nums = [2,2,2]
Output
1
Constraints
1 <= nums.length <= 12
0 <= nums[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Number of Squareful Arrays.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.