Problem Brief
Top-K KOLs by Total Likes
FULLTIMEONSITE INTERVIEW
See Tiktok online assessment and hiring insightsYou are given a sequence of like events. The i-th event contributes likeCounts[i] likes to creator kolIds[i].
Aggregate total likes per creator, then return the top k creators sorted by total likes descending. Break ties by creator ID ascending.
Return each ranked result as a single string formatted "creator totalLikes".
Function Description
Complete the function topKKolsByLikes in the editor below.
topKKolsByLikes has the following parameters:
String[] kolIds: creator identifiersint[] likeCounts: likes contributed by each eventint k: the number of creators to return
Returns
String[]: the top k ranked creator totals.
1Example 1
Input
kolIds = ["A", "B", "A", "C", "B", "D"], likeCounts = [1, 5, 3, 2, 1, 10], k = 2
Output
["D 10", "B 6"]
Explanation
D has the highest total likes, followed by B.
2Example 2
Input
kolIds = ["ann", "bob", "ann", "bob"], likeCounts = [2, 1, 1, 2], k = 2
Output
["ann 3", "bob 3"]
Explanation
Both creators tie at 3 total likes, so ID order breaks the tie.
Constraints
Limits and guarantees your solution can rely on.
1 <= kolIds.length == likeCounts.length <= 2 * 10^51 <= k <=the number of distinct creators0 <= likeCounts[i] <= 10^9