Your question is Solve Task Completion with Engineers. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
PhonePe needs to complete n independent tasks using m engineers. Engineer i has power powers[i]. If that engineer completes k tasks, the total time spent is powers[i] * (1 + 2 + ... + k) days. Tasks assigned to the same engineer are completed sequentially, while all engineers work in parallel.
Return the minimum number of days required to complete at least n tasks.
Implement min_days(n, powers):
n, the number of tasks, and an integer array powers, where powers[i] is the time multiplier for engineer i.For a candidate duration d, engineer i can complete the largest k satisfying powers[i] * k * (k + 1) / 2 <= d. Use this relationship to test feasibility efficiently.
def min_days(n, powers):