Ethos Life OA Question
Summary
I encountered a challenging server load balancing problem during my online assessment for Ethos Life. The problem required careful consideration of manual offloading and an automated management tool to minimize operations.
Full Experience
During my online assessment with Ethos Life, I was presented with a complex algorithmic problem related to server load balancing. The task was to minimize the number of times a specific management tool was used, given that I could also manually offload tasks from a limited number of servers. This problem required a strategic approach to combine both methods efficiently.
Interview Questions (1)
Problem Statement
You are given a set of servers, each with a different workload represented as an integer in an array serverLoad. The goal is to balance the server workloads by offloading tasks.
You can offload tasks in two ways:
- Manually Offloading – You can manually offload tasks from at most
kservers. - Using the Management Tool – This tool:
- Identifies the server with the highest workload, denoted as
L. - Offloads tasks from all servers with a workload strictly greater than
L/2in a single operation. - Each time you use the tool, it incurs a resource cost.
- Identifies the server with the highest workload, denoted as
Your task is to minimize the number of times the tool is used while ensuring the workloads are balanced. Return the minimum number of times the tool must be operated.
Example
Input:
serverLoad = [16, 12, 18, 10, 12]
k = 2
Output:
1