Basic brute-force style approach in Kotlin - O(n*k) and $$O(k)
Pretty basic first approach that came to mind. This is probably not good enough for an interview on it\'s own, however could be a decent starting point for you 
Pretty basic first approach that came to mind. This is probably not good enough for an interview on it\'s own, however could be a decent starting point for you to make some optimizations when asked, such as using a min heap and an ordered set instead of the IntArrays, as in my [improved solution.](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests/solutions/3928951/min-heap-priorityqueue-and-ordered-set-treeset-in-kotlin/)\n\n# Intuition\nStore the time each server will be available again after a request, loop through for each request and see if it can take the request.\n\n# Approach\n- Set all servers to be free at -1, so they are all able to take requests at the start.\n- Set all of the servers requests taken to 0.\n- Loop through requests, if the request start time is larger than the servers "free" time, it can take the request, so set it\'s next available time to the time of the request + the load, and increment requests taken.\n- Reset the server counter if it loops around all of them.\n- Go through requests taken and return the servers with largest values.\n\n# Complexity\n- Time complexity: $$O(n*k)$$\n\n- Space complexity: $$O(k)$$\n\n# Code\n```\nclass Solution {\n    fun busiestServers(k: Int, arrival: IntArray, load: IntArray): List<Int> {\n        val freeTimes = IntArray(k) { -1 }\n        val requestsTaken = IntArray(k) { 0 }\n\n        for (requestNumber in 0 until arrival.size) {\n            var i = 0\n            var currentServer = requestNumber % k\n            while (i < k) {\n                if (currentServer == k) {\n                    currentServer = 0\n                }\n                if (freeTimes[currentServer] <= arrival[requestNumber]) {\n                    freeTimes[currentServer] = arrival[requestNumber] + load[requestNumber]\n                    requestsTaken[currentServer]++\n                    currentServer++\n                    break\n                }\n                currentServer++\n                i++\n            }\n        }\n\n        var maxLoad = 0\n        var result = mutableListOf<Int>()\n        for ((server, load) in requestsTaken.withIndex()) {\n            if (load > maxLoad) {\n                maxLoad = load\n                result = mutableListOf(server)\n            } else if (load == maxLoad) {\n                result.add(server)\n            }\n        }\n\n        return result\n    }\n}\n```
['Kotlin']