FastPrepTop-K KOLs by Total Likes
Problems/Top-K KOLs by Total Likes

Top-K KOLs by Total Likes

TikTok logoTikTok● EasyFULLTIMEONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You 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

topKKolsByLikes(kolIds: String[], likeCounts: int[], k: int) → String[]

Complete the function topKKolsByLikes in the editor below.

topKKolsByLikes has the following parameters:

  1. String[] kolIds: creator identifiers
  2. int[] likeCounts: likes contributed by each event
  3. int k: the number of creators to return

Returns String[]: the top k ranked creator totals.

Examples

Example 1

kolIds = ["A", "B", "A", "C", "B", "D"]likeCounts = [1, 5, 3, 2, 1, 10]k = 2return = ["D 10", "B 6"]

D has the highest total likes, followed by B.

Example 2

kolIds = ["ann", "bob", "ann", "bob"]likeCounts = [2, 1, 1, 2]k = 2return = ["ann 3", "bob 3"]

Both creators tie at 3 total likes, so ID order breaks the tie.

Constraints

  • 1 <= kolIds.length == likeCounts.length <= 2 * 10^5
  • 1 <= k <= the number of distinct creators
  • 0 <= likeCounts[i] <= 10^9

More TikTok interview questions

  • LRU Cache with TTL ExpirationONSITE INTERVIEW · Seen May 2026
  • Maximum Candies with At Most Two Types in a LineONSITE INTERVIEW · Seen May 2026
  • Center of the Largest Perfect X-ShapeOA · Seen Nov 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Nov 2026
  • Count Suffix Word PairsOA · Seen Nov 2026
  • Minimum Cost of Every K-Capable Model SetOA · Seen Nov 2026
  • Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Oct 2026
  • Next Greater Indices and Maximum GapPHONE SCREEN · Seen Oct 2026
  • Count Subarrays with at Least K Equal-Fruit PairsOA · Seen Oct 2026
  • Shell Command Counts with History ReferencesOA · Seen Oct 2026

Similar questions at other companies

  • Top K Frequent ElementsEricsson · ONSITE INTERVIEWEricsson interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Top K Frequent WordsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Top K Frequent ElementsCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Top K Frequent Elements with Larger-Value Tie BreakOracle · ONSITE INTERVIEWOracle interview questions
  • Top K Frequent ElementsInfosys · ONSITE INTERVIEWInfosys interview questions
  • Top-K IP Addresses from File RecordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Top K Keys from JSON RecordsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Progressive Banking SystemAirbnb · OAAirbnb interview questions

TikTok interview experiences

  • TikTok AI Infra Intern LLM Round 2: 1 Experience
  • TikTok AI Infra Intern DeepSpeed Round: 1 Experience
  • TikTok AI Infra Intern Kernel Round: 1 Experience
  • TikTok AI Infra Intern Interviews, 3 Rounds: 1 Experience
  • TikTok AI Infra Intern Interview Timeline: 1 Experience
  • TikTok AI Infra Intern Onsite Round 2: 1 Experience
All TikTok interview questionsSee TikTok hiring insights
Saved
class Solution {
    public String[] topKKolsByLikes(String[] kolIds, int[] likeCounts, int k) {
        // write your code here
    }

}
Checking account…