My solution is around O(n^2). Most of my solutions include looping over the tasks, then in said loop, loop over either all tasks or a subset of the tasks.