Company: DTCC

Difficulty: medium

Problem Statement

Top K APIs by Cumulative Load Given `n` API-call events, the `i`-th event has API index `apiIndex[i]` and load `loads[i]`. Add the loads belonging to the same API index. Return the `k` API indices with the highest cumulative loads. Sort the selected indices by decreasing cumulative load. If two indices have equal cumulative load, place the smaller index first. Input Format The first line contains `n`. The second line contains `n` integers, `apiIndex`. The third line contains `n` integers, `loads`. The fourth line contains `k`. Output Format Print the selected indices in order, separated by one space. Constraints `1 ≤ n ≤ 200000`, `1 ≤ apiIndex[i] ≤ n`, `1 ≤ loads[i] ≤ 10^9`, `1 ≤ k ≤ n`. At least `k` distinct API indices have non-zero cumulative load. Use 64-bit integers for cumulative loads. Example Input `3` `1 2 3` `10 10 15` `2` Output `3 1` API 3 has total load 15. APIs 1 and 2 tie at 10, so API 1 is chosen first. Notes Only indices occurring in `apiIndex` are cand

More DTCC OA questionsInterview experiences