Find Most Frequent Function Call Path in Stack Trace
Given a list representing a stack trace with function calls and returns (indicated by '->' and '<-'), find the function call path that occurs most frequently. If multiple paths have the same frequency, return the one that occurred first.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid June, 2026
Late January, 2026
The list (example) is similar to the following: " -> main" " -> clickHandler" " -> clickExecutor" " <- clickExecutor" " <- clickHandler" " -> clickHandler" " <- clickHandler" " -> mouseHandler" " <- mouseHandler" " <- main" The expected result would be "main -> clickHandler" which is a path that occured twice. While "main -> clickHandler -> clickExecutor" and "main -> mouseHandler" occured once. In the event that more than one stack trace has the same frequency, return the one that occurred first.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.