I have the following problem: You are given a todo list, some items of which depend on others. Write a function that takes a subset of those todos and returns an ordered list of
Instead of taking a separate filtering pass, you should be able to check each task for addition to the output filteredTasks
as it is processed for addition to orderedTasks
.
Since the only other use of orderedTasks
is to check its length, you should then be able to replace it with a counter.
This might not make your function much faster, but it will simplify your code.