You are given an integer array nums and an integer k.
The cost of a subarray is defined as the product of the difference between its maximum and minimum elements and its length:
You are given an integer array nums and an integer k.
The cost of a subarray is defined as the product of the difference between its maximum and minimum elements and its length: