FastPrepLog Analyzer: Busiest Service in a Rolling Window
Problems/Log Analyzer: Busiest Service in a Rolling Window

Log Analyzer: Busiest Service in a Rolling Window

ByteDance logoByteDance● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a ByteDance software engineer intern video interview for the TikTok U.S. Data Security team. The task was to read request logs, each with a time in seconds and a service name, find the service with the most requests inside any rolling window of t seconds, and give back that count together with every service that ties for it. The three worked examples show that the logs may come in any order and that a window includes both of its ends.

The report does not say how the answer should be laid out, in which order tied services are listed, or how large the input can be. Here, the answer is one row of name and count for each tied service, sorted by name, and we use up to 2 * 10^4 logs, times up to 10^9 and service names of up to 10 capital letters.

Our version is about 90% the same as the reported question.

You are given the request logs of several services. Log i says that the service named services[i] received one request at second timestamps[i]. The logs can be in any order, and a service can receive several requests in the same second.

A window of t seconds covers every time from some second s up to s + t, including both ends. So two requests at times a <= b can be in the same window exactly when b - a <= t.

For each service, find the largest number of its own requests that fit in one window. A service is busiest if no other service has a larger number.

Return one row [name, count] for every busiest service, where count is that largest number written as a decimal string. If several services tie, return all of them, with the rows sorted by service name in the usual string order (so "AB" comes before "B").

Function

busiestServices(timestamps: int[], services: String[], t: int) → String[][]

Examples

Example 1

timestamps = [10,40,100,200,260,280,310,210]services = ["A","B","A","A","B","A","B","A"]t = 300return = [["A","5"]]
  • The logs are not in time order. Sorted, service "A" has requests at 10, 100, 200, 210 and 280, and service "B" at 40, 260 and 310.
  • The window from 10 to 310 holds all 5 requests of "A", because 280 - 10 = 270 <= 300.
  • All 3 requests of "B" also fit in one window (310 - 40 = 270), but 3 < 5.
  • The busiest service is "A" with 5 requests.

Example 2

timestamps = [10,20,30,40,50,60,70]services = ["A","B","A","B","A","B","A"]t = 60return = [["A","4"]]
  • Service "A" has requests at 10, 30, 50 and 70. The window from 10 to 70 is exactly 60 seconds long and includes both ends, so it holds all 4.
  • Service "B" has requests at 20, 40 and 60, so its best window holds 3.
  • The answer is "A" with 4 requests.

Example 3

timestamps = [100,100,100,100,110,110]services = ["A","A","B","B","B","A"]t = 10return = [["A","3"],["B","3"]]
  • Service "A" has requests at 100, 100 and 110. Two requests at the same second count separately, and 110 - 100 = 10, so one window holds all 3.
  • Service "B" has the same times, so it also reaches 3.
  • Both services tie, so both are returned, sorted by name: "A" first, then "B".

Constraints

  • 1 <= timestamps.length <= 2 * 10^4
  • services.length == timestamps.length
  • 0 <= timestamps[i] <= 10^9
  • 1 <= t <= 10^9
  • services[i] has 1 to 10 characters, and each one is an uppercase English letter.

More ByteDance Phone Screen questions

  • Largest Number Below N from Reusable DigitsPHONE SCREEN · Seen Nov 2026
  • Majority ElementPHONE SCREEN · Seen Nov 2026
  • Valid ParenthesesPHONE SCREEN · Seen Nov 2026
  • Binary Tree Target-Sum PathsPHONE SCREEN · Seen Nov 2026
  • Longest Increasing SubsequencePHONE SCREEN · Seen Nov 2026
  • Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Number of Events That Can Be AttendedPHONE SCREEN · Seen Nov 2026
  • Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Meeting RoomsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Message Event AggregationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Interview Slot BookingTrueFoundry · PHONE SCREEN
  • HTTP Log QueriesDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top K Best-Selling Products in the Last N DaysAmazon · ONSITE INTERVIEW
  • Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Count Redundant File BackupsGoldman Sachs · OAGoldman Sachs interview questions

Interview reports that mention this question

  • ByteDance TikTok USDS SWE Intern Interview: 1 Experience

ByteDance interview experiences

  • ByteDance MLE New Grad Interviews: 1 Experience
  • ByteDance Security SRE Intern Phone Screens: 1 Experience
  • ByteDance USDS New Grad SWE Phone Screen: 1 Experience
  • ByteDance New Grad Data Engineer Video Interviews: 1 Experience
  • ByteDance Trust & Safety Research Scientist Intern: 1 Experience
All ByteDance interview questionsSee ByteDance hiring insights
Saved
class Solution {
    public String[][] busiestServices(int[] timestamps, String[] services, int t) {
        // Write your code here.
    }
}
Checking account…