Problem Β· Array
Kth Smallest in Subarray π
Learn this problemProblem statement
Given an array arr, return the kth smallest integer for each subarray of size m.
Function
kthSmallestInSubarray(arr: int[], k: int, m: int) β int[]Examples
Example 1
arr = [3, 1, 4, 2]k = 2m = 3return = [3, 2]In the first subarray of size 3 ([3,1,4]) the 2nd smallest element is 3. In the second subarray of size 3 ([1,4,2]) the 2nd smallest element is 2.