Your question is LeetCode-Style Coding Task. 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.
An AMD ROCm runtime must schedule kernel launches on a command stream. Kernels with the same name require at least n other time slots between launches of that kernel. Each slot can run one kernel, or remain idle. Return the minimum number of slots needed to execute all launches.
Implement least_interval(tasks, n), where tasks is a list of strings representing kernel names and n is a nonnegative integer cooldown. Return an integer representing the shortest valid schedule length. You may reorder the launches, but every launch must execute exactly once.
def least_interval(tasks, n):