mediumArrayEnumerationHash TableMath 0 views

Count Special Subsequences

You are given an array nums consisting of positive integers.

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), where p < q < r < s. This subsequence must satisfy the following conditions:

Return the number of different special subsequences in nums.

Count Special Subsequences diagram

Example 1

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

Output: 1

Explanation: There is one special subsequence in nums .

Example 2

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

Output: 3

Explanation: There are three special subsequences in nums .

Constraints

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

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.