Skip to content

Practice Count Special Subsequences

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3404
LeetCode Problem

Count Special Subsequences

Problem Statement

Given nums, count index quadruples p < q < r < s such that nums[p] * nums[r] equals nums[q] * nums[s], with at least one unused index between each adjacent chosen pair: q - p > 1, r - q > 1, and s - r > 1.

Source: Count Special Subsequences on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,4,3,6,1]
Output
1

# Example 2

Input
nums = [3,4,3,4,3,4,3,4]
Output
3

Constraints

7 <= nums.length <= 1000
1 <= nums[i] <= 1000

Related LeetCode Problems

Practice more problems similar to Count Special Subsequences.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.