Max Likes
Learn this problemProblem 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[]) → intExamples
Example 1
prediction = [1, 3, 2]return = 4More Tiktok problems
- Can Reach the Exit with TeleportsOA · Seen Jul 2026
- Check Monotonic TriplesOA · Seen Jul 2026
- Shift Every K-th ConsonantOA · Seen Jul 2026
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Sort Matrix BordersOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Validate 3x3 Digit WindowsOA · Seen Jul 2026