996. Number of Squareful Arrays Hard
1/**
2 * [996] Number of Squareful Arrays
3 *
4 * An array is squareful if the sum of every pair of adjacent elements is a perfect square.
5 * Given an integer array nums, return the number of permutations of nums that are squareful.
6 * Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].
7 *
8 * Example 1:
9 *
10 * Input: nums = [1,17,8]
11 * Output: 2
12 * Explanation: [1,8,17] and [17,8,1] are the valid permutations.
13 *
14 * Example 2:
15 *
16 * Input: nums = [2,2,2]
17 * Output: 1
18 *
19 *
20 * Constraints:
21 *
22 * 1 <= nums.length <= 12
23 * 0 <= nums[i] <= 10^9
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/number-of-squareful-arrays/
29// discuss: https://leetcode.com/problems/number-of-squareful-arrays/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn num_squareful_perms(nums: Vec<i32>) -> i32 {
35 0
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_996() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.