Top K Frequent IP Addresses

Asked at NewsBreak · Coding Questions · Difficulty: Medium

Given a string representing a multi-line log file where each line contains an IP address, write a function to find the top `k` frequent IP addresses. Assume `k` is a positive integer not greater than the number of unique IP addresses. The output should be a list of `k` tuples with the IP address and its frequency.

Loading the problem…