Data Structures19 sections · 729 units
Open in Course

Problem - Kth Smallest in Range

Online quantile queries

Given an array, answer queries: "What is the kk-th smallest element in subarray A[l..r]A[l..r]?" Example: A=[1,5,2,4,3]A = [1, 5, 2, 4, 3] Query (0,3,3)(0, 3, 3): 3rd smallest in [1,5,2,4][1, 5, 2, 4] is 44.

You're solving the range quantile problem. Common in database systems for percentile queries. Note: LeetCode has related problems, but this specific online query version often appears in competitive programming.