FastPrepMax Likes
Problems/Max Likes

Max Likes

TikTok logoTikTok● MediumOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

You are a TT content creator with predictions about which trends will be popular over the next n days. These trends are represented by an array prediction, where the trend that will be popular on the i-th day is given by prediction[i].

Before the trends gain popularity, you need to select a set of trends to focus on. For each trend x that you choose, you will earn x likes each time that trend appears in the prediction array. However,to maintain diversity in your content, if you choose the x-th trend, you cannot choose the (x-1)-th or (x+1)-th trends, as they are considered too similar.

Your objective is to maximize the number of likes you can earn by carefully selecting which trends to focus on. Since the number of like can be large, return your answer modulo 10^9 + 7.

Function

maxLikes(prediction: int[]) → int

Examples

Example 1

prediction = [1, 3, 2]return = 4

Choose trends 1 and 3. You will get 1 like on the first day and 3 likes on the second day. The total number of likes is 4.

More TikTok interview questions

  • 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
  • Product Minus Sum of DigitsOA · Seen Aug 2026
  • Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026

Similar questions at other companies

  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Points by Deleting ElementsIBM · OAIBM interview questions
  • Longest String ChainVisa · OAVisa interview questions
  • Maximum Points by Deleting ElementsWalmart · OAWalmart interview questions
  • Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Count Equal-Frequency SubsequencesExpedia · OAExpedia interview questions
  • Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
  • Longest String ChainLinkedIn · OALinkedIn interview questions
  • Count Valid SequencesOpenAI · OAOpenAI interview questions
  • Find the Maximum Length of a Good Subsequence I (LC 3176 :)Snowflake · OASnowflake 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 int maxLikes(int[] prediction) {
      // write your code here
    }

}
Checking account…