Class Solution
- java.lang.Object
-
- g0901_1000.s0996_number_of_squareful_arrays.Solution
-
public class Solution extends Object
996 - Number of Squareful Arrays.Hard
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
numsthat are squareful.Two permutations
perm1andperm2are different if there is some indexisuch thatperm1[i] != perm2[i].Example 1:
Input: nums = [1,17,8]
Output: 2
Explanation: [1,8,17] and [17,8,1] are the valid permutations.
Example 2:
Input: nums = [2,2,2]
Output: 1
Constraints:
1 <= nums.length <= 120 <= nums[i] <= 109
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intnumSquarefulPerms(int[] nums)
-