1995. Count Special Quadruplets Easy
1/**
2 * [1995] Count Special Quadruplets
3 *
4 * Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:
5 *
6 * nums[a] + nums[b] + nums[c] == nums[d], and
7 * a < b < c < d
8 *
9 *
10 * Example 1:
11 *
12 * Input: nums = [1,2,3,6]
13 * Output: 1
14 * Explanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.
15 *
16 * Example 2:
17 *
18 * Input: nums = [3,3,6,4,5]
19 * Output: 0
20 * Explanation: There are no such quadruplets in [3,3,6,4,5].
21 *
22 * Example 3:
23 *
24 * Input: nums = [1,1,1,3,5]
25 * Output: 4
26 * Explanation: The 4 quadruplets that satisfy the requirement are:
27 * - (0, 1, 2, 3): 1 + 1 + 1 == 3
28 * - (0, 1, 3, 4): 1 + 1 + 3 == 5
29 * - (0, 2, 3, 4): 1 + 1 + 3 == 5
30 * - (1, 2, 3, 4): 1 + 1 + 3 == 5
31 *
32 *
33 * Constraints:
34 *
35 * 4 <= nums.length <= 50
36 * 1 <= nums[i] <= 100
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/count-special-quadruplets/
42// discuss: https://leetcode.com/problems/count-special-quadruplets/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn count_quadruplets(nums: Vec<i32>) -> i32 {
48 0
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_1995() {
60 }
61}
62
Back
© 2025 bowen.ge All Rights Reserved.