FastPrepMost Frequent Call Path From Function Trace Logs
Problems/Most Frequent Call Path From Function Trace Logs

Most Frequent Call Path From Function Trace Logs

Roblox logoRoblox● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This corrected practice version is about an 85% match to nine original author-written Roblox reports. Parsing enter/return traces with a stack, counting full call paths, preferring greater depth when frequencies tie, and then preferring the path that appeared first come directly from the reports. The exact signature, arrow-spacing tolerance, empty-input result, constraints, examples, and listed follow-ups are bounded practice details.

You are given single-threaded function trace logs. Each line records either entering a function or returning from one. Scan the logs from left to right while maintaining the active call stack.

Whenever a function is entered, count the full active call path from the root to the current function. Join function names with ->.

Return the path with the greatest frequency. If frequencies tie, return the deeper path. If frequency and depth both tie, return the path whose first appearance in the trace occurs earlier.

Each line is "-> name" for entry or "<- name" for return. This executable version also accepts no space after the arrow. The trace is well formed, so every return matches the active stack's top.

Function

mostFrequentCallPath(traces: String[]) → String

Examples

Example 1

traces = ["-> main", "-> handleEvents", "-> handleClickEvent", "<- handleClickEvent", "-> handleClickEvent", "<- handleClickEvent", "<- handleEvents", "<- main"]return = "main->handleEvents->handleClickEvent"

The paths main and main->handleEvents are each counted once. The path main->handleEvents->handleClickEvent is counted twice, so it is returned.

Example 2

traces = ["-> main", "-> handleEvents", "-> handleKeyEvent", "<- handleKeyEvent", "-> handleClickEvent", "<- handleClickEvent", "-> handleClickEvent", "<- handleClickEvent", "-> handleKeyEvent", "<- handleKeyEvent", "<- handleEvents", "<- main"]return = "main->handleEvents->handleKeyEvent"

The two leaf paths each occur twice at the same depth. The handleKeyEvent path appeared first, so it wins the final tie-break.

Example 3

traces = ["-> A", "-> B", "<- B", "<- A"]return = "A->B"

A and A->B both occur once. A->B is deeper, so it wins the tie.

Example 4

traces = []return = ""

There are no entered functions, so the answer is the empty string.

Example 5

traces = ["->main", "->worker", "<-worker", "<-main"]return = "main->worker"

The parser should accept trace lines without spaces after the arrow. The deeper path wins because both paths occur once.

Constraints

  • 0 <= traces.length <= 100000
  • Each line starts with -> or <-.
  • Function names contain letters, digits, or underscores.
  • The trace is well formed and balanced.
  • If traces is empty, return the empty string.

More Roblox Phone Screen questions

  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026
  • Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • Number of AtomsAmazon · ONSITE INTERVIEW
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
  • Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
  • Number Words to Digits in Any LanguageMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public String mostFrequentCallPath(String[] traces) {
      // write your code here
    }
}
Checking account…