Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2552 - Count Increasing Quadruplets\.

    Hard

    Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.

    A quadruplet (i, j, k, l) is increasing if:

    • 0 <= i < j < k < l < n, and

    • nums[i] < nums[k] < nums[j] < nums[l].

    Example 1:

    Input: nums = 1,3,2,4,5

    Output: 2

    Explanation:

    • When i = 0, j = 1, k = 2, and l = 3, numsi< numsk< numsj< numsl.

    • When i = 0, j = 1, k = 2, and l = 4, numsi< numsk< numsj< numsl. There are no other quadruplets, so we return 2.

    Example 2:

    Input: nums = 1,2,3,4

    Output: 0

    Explanation:

    There exists only one quadruplet with i = 0, j = 1, k = 2, l = 3, but since numsj< numsk, we return 0.

    Constraints:

    • 4 &lt;= nums.length &lt;= 4000

    • 1 &lt;= nums[i] &lt;= nums.length

    • All the integers of nums are unique. nums is a permutation.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Long countQuadruplets(IntArray nums)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait