Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Cost Less Than or Equal to K

Count Subarrays With Cost Less Than or Equal to K asks you to count contiguous subarrays of an integer array where the difference between maximum and minimum, multiplied by length, is at most k.

Statement

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:

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Cost Less Than or Equal to K

Count Subarrays With Cost Less Than or Equal to K asks you to count contiguous subarrays of an integer array where the difference between maximum and minimum, multiplied by length, is at most k.

Statement

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: