Back to problems

Count Reversing Triples

Algorithm · Affirm · Medium

Given an integer array nums, your task is to count the number of index triplets (i, j, k) satisfying i nums[j] > nums[k]. Return the total number of such triplets. Constraints: 0 ≤ nums.length ≤ 10⁴ -10⁵ ≤ nums[i] ≤ 10⁵ Example 1: Input: nums = [4, 1, 5, 3, 2] Output: 2 Explanation: Only the two triplets corresponding to values [4, 3, 2] and [5, 3, 2] satisfy the strict decreasing condition across increasing indices. Example 2: Input: nums = [5, 4, 3, 2, 1] Output: 10…

Checking your access…