Skip to content

Practice Subarray With Elements Greater Than Varying Threshold

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

Hard#2334
LeetCode Problem

Subarray With Elements Greater Than Varying Threshold

Problem Statement

You are given an integer array nums and an integer threshold. Find any subarray of nums of length k such that every element in the subarray is greater than threshold / k. Return the size of any such subarray. If there is no such subarray, return -1. A subarray is a contiguous non-empty sequence of elements within an array.

Source: Subarray With Elements Greater Than Varying Threshold on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,3,4,3,1], threshold = 6
Output
3

# Example 2

Input
nums = [6,5,6,5,8], threshold = 7
Output
1

Constraints

1 <= nums.length <= 10^5
1 <= nums[i], threshold <= 10^9

Related LeetCode Problems

Practice more problems similar to Subarray With Elements Greater Than Varying Threshold.

Review your practice with PhantomCodeAI

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