educative.io

Job Class Is Incomplete

Just so people know, the job class given in the challenge problem 2 is not the same as the one defined in the solution review. The solution review has an additional definition for a magic operator (<) as pasted below:

def lt(self, other):
# min heap based on job.end
return self.end < other.end

Without this defined, I was getting an error like:

TypeError: unorderable types: job() < job()


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Problem Challenge 2 - Grokking the Coding Interview: Patterns for Coding Questions

Hi @Eric_Onofrey, Thanks for reaching out to us.
The job class in Problem Challenge 2 is not incomplete because when you implement the find_max_cpu_load(jobs) function you will be working with minheap so for minheap you have to create def __lt__(self, other) as well, so this is part of the solution that’s why not written in the challenge so that you can think about it and can not get any hint.

Hope it will help :slight_smile:

1 Like