As reported: Goldman Sachs CoderPad / coding rounds (2025): find the most frequent IP address in log records — solved in O(n) time and space (Associate); "Max IP Count" from log data with follow-ups and corner cases (Analyst); an Apache log with IP addresses where the IP with the highest frequency is returned and ties are returned comma-separated (Associate, GBM).
You are given the lines of a web server (Apache-style) access log. Each line starts with the client IP address, followed by a space and the rest of the entry.
Return the IP address that appears most often. If several IPs share the highest count, return all of them in ascending (string) order, separated by commas with no spaces.
Example 1
lines = ["10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234",
"10.0.0.1 - frank [10/Dec/2000:12:34:57 -0500] \"GET /b.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234"]
-> "10.0.0.1"
Example 2
the same log plus one more line from 10.0.0.2
-> "10.0.0.1,10.0.0.2"
Constraints: 1 ≤ lines.length ≤ 10^5; every line is non-empty and starts with an IP address followed by a space.
Code runner format: one JSON value per line: lines (a JSON array of strings). Implement findTopIpAddress(lines); the harness prints the returned string as JSON.