The array rating contains distinct ratings in lineup order. Count triples of indices i < j < k whose ratings are either strictly increasing or strictly decreasing. An index may participate in multiple triples. Return the total number of valid triples.
Example 1:
Input: rating = [4,3,2]
Output: 1Explanation: The only triple uses all three entries, and 4 > 3 > 2 makes it a valid decreasing team.
Example 2:
Input: rating = [1,3,2]
Output: 0Explanation: The only triple has ratings 1, 3, 2, which are neither strictly increasing nor strictly decreasing.
Example 3:
Input: rating = [1,4,2,3]
Output: 1Explanation: The only valid team uses indices (0, 2, 3), with ratings 1 < 2 < 3. The other three triples fail both order conditions.
Constraints:
3 <= rating.length <= 10001 <= rating[i] <= 100000- All ratings are distinct.