Practice Sliding Subarray Beauty
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an integer array nums containing n integers, find the beauty of each subarray of size k. The beauty of a subarray is the xth smallest integer in the subarray if it is negative, or 0 if there are fewer than x negative integers. Return an integer array containing n - k + 1 integers, which denote the beauty of the subarrays in order from the first index in the array.
Source: Sliding Subarray Beauty on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,-1,-3,-2,3], k = 3, x = 2
[-1,-2,-2]
# Example 2
nums = [-1,-2,-3,-4,-5], k = 2, x = 2
[-1,-2,-3,-4]
# Example 3
nums = [-3,1,2,-3,0,-3], k = 2, x = 1
[-3,0,-3,-3,-3]
Constraints
Related LeetCode Problems
Practice more problems similar to Sliding Subarray Beauty.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.