Skip to content

Practice Count Subarrays With Score Less Than K

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2302
LeetCode Problem

Count Subarrays With Score Less Than K

Problem Statement

The score of an array is defined as the product of its sum and its length. Given a positive integer array nums and an integer k, return the number of non-empty subarrays of nums whose score is strictly less than k. A subarray is a contiguous sequence of elements within an array.

Source: Count Subarrays With Score Less Than K on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,1,4,3,5], k = 10
Output
6

# Example 2

Input
nums = [1,1,1], k = 5
Output
5

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^5
1 <= k <= 10^15

Related LeetCode Problems

Practice more problems similar to Count Subarrays With Score Less Than K.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.