121. Summarize Endpoint Latencies
MediumSorting and ranks
Each sample is [endpoint, nonnegative latency]. Collect the latencies for each endpoint and compute the nearest-rank percentile.
For an endpoint with n samples sorted in ascending order, return the sample at one-based rank ceil(n × percentile / 100). Return [endpoint, latency] pairs in the order the endpoints first appear.
Example 1
Input: samples = [["search",40],["status",2],["search",10],["search",50],["status",1]], percentile = 50 Output: [["search",40],["status",1]]
Example 2
Input: samples = [["up",5],["up",1],["up",1],["up",6]], percentile = 75 Output: [["up",5]]
Constraints
At most 100,000 samples.Percentile is an integer from 1 to 100. Latencies are integer milliseconds.