3404. Count Special Subsequences
You are given an array
nums
consisting of positive integers.A special subsequence is defined as a subsequence of length 4, represented by indices
(p, q, r, s)
, wherep < q < r < s
. This subsequence must satisfy the following conditions:
nums[p] * nums[r] == nums[q] * nums[s]
- There must be at least one element between each pair of indices. In other words,
q - p > 1
,r - q > 1
ands - r > 1
.A subsequence is a sequence derived from the array by deleting zero or more elements without changing the order of the remaining elements.
Return the number of different special subsequences in
nums
.
1 | class Solution { |