PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to perform frequency analysis on sequences, demonstrating competency with data structures for counting occurrences and with algorithmic time and space complexity considerations.

  • easy
  • Roblox
  • Coding & Algorithms
  • Machine Learning Engineer

Find the Most Frequent Log Call

Company: Roblox

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are given a sequence of application log entries. Each entry contains the name of a function or API call made by the system. Write a function that returns the call that appears most frequently in the logs, along with its frequency. Example: - Input: ["login", "search", "login", "checkout", "search", "login"] - Output: ("login", 3) Follow-up discussion can include how to handle ties, how to return the top-k most frequent calls, and how to process logs in a streaming or large-scale setting.

Quick Answer: This question evaluates a candidate's ability to perform frequency analysis on sequences, demonstrating competency with data structures for counting occurrences and with algorithmic time and space complexity considerations.

You are given a sequence of application log entries as a list of strings, where each entry is the name of a function or API call made by the system. Return the call that appears most frequently in the logs, along with its frequency, as a pair `(call, frequency)`. If multiple calls are tied for the highest frequency, return the one that first appears earliest in the log sequence. If the log is empty, return `("", 0)`. Example: - Input: ["login", "search", "login", "checkout", "search", "login"] - Output: ("login", 3) Follow-up directions you could discuss in an interview: how to handle ties, how to return the top-k most frequent calls, and how to process logs in a streaming or large-scale (multi-machine) setting.

Constraints

  • 0 <= len(logs) <= 10^6
  • Each log entry is a non-empty string of an API/function call name.
  • Ties are broken by earliest first appearance in the log sequence.
  • Return ("", 0) for an empty log.

Examples

Input: (["login", "search", "login", "checkout", "search", "login"],)

Expected Output: ("login", 3)

Explanation: "login" appears 3 times, more than "search" (2) and "checkout" (1).

Input: (["a", "b", "a", "b"],)

Expected Output: ("a", 2)

Explanation: "a" and "b" both appear twice; "a" appears first, so it wins the tie.

Input: (["solo"],)

Expected Output: ("solo", 1)

Explanation: A single entry is trivially the most frequent.

Input: ([],)

Expected Output: ("", 0)

Explanation: Empty log returns the sentinel ("", 0).

Input: (["x", "y", "z"],)

Expected Output: ("x", 1)

Explanation: All unique with frequency 1; the earliest-appearing "x" wins the tie.

Input: (["api", "api", "api", "api"],)

Expected Output: ("api", 4)

Explanation: A single repeated call accumulates the full count.

Hints

  1. Use a hash map to count occurrences of each call in a single pass.
  2. Track each call's first-appearance index so you can break frequency ties deterministically.
  3. For the top-k follow-up, a heap of size k or bucket sort by frequency avoids fully sorting all distinct calls; for streaming/large-scale, think Count-Min Sketch or a map-reduce word-count.
Last updated: Jun 26, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Windows Containing a Target - Roblox (medium)
  • Implement Sliding-Window Rate Limiter - Roblox (medium)
  • Find target-heavy sliding windows - Roblox (medium)
  • Find most frequent call path in logs - Roblox (medium)
  • Track Highest-Earning Experience - Roblox (medium)