TikRouter Delivers
Learn this problemProblem statement
Imagine you're in charge of TikTok's servers, where millions of videos, comments, and likes are constantly flowing between users.
TikTok needs to send these small packets of data across its network to keep users' feeds smooth and up-to-date. However, there's a catch! The TikTok delivery drone, which we'll call TikRouter, can only carry a limited amount of data on each trip between servers.
- Each "like," comment, or part of a video clip is between 1.01 bytes and 3.00 bytes in size. - TikRouter is responsible for delivering these packets of interactions to TikTok's users but can carry only up to 3.00 bytes per trip.
As the network administrator in charge of TikRouter, your goal is to minimize the number of trips it makes. Each time TikRouter makes a trip, it grabs as many likes, comments, and video snippets as it can without exceeding the 3.00-byte limit. After each delivery, TikRouter returns for more until all packets are delivered.
Your challenge is to design an efficient algorithm that helps TikRouter determine the minimum number of trips required to deliver n packets of varying sizes.
Function
findMinimumTripsByTikRouter(packet_sizes: float[]) → int
Complete the function findMinimumTripsByTikRouter in the editor below.
findMinimumTripsByTikRouter has the following parameter(s):
float packet_sizes[n]: size of the data packets (in bytes)
Returns
int: the minimum number of trips required
Examples
Example 1
packet_sizes = [1.01, 1.99, 2.5]return = 2TikRouter can deliver all the data packets in two trips: [1.01 + 1.99, 2.5].
Thus, the answer is 2.
Constraints
🍉🍉More 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