Grokking Meta Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
How does just pushing ' points[i]' let the heap know how to maintain the furthes...

Derek Yu

Jul 21, 2022

How does just pushing ' points[i]' let the heap know how to maintain the furthest distance in the heap?

0

0

Comments
Design Gurus
Design Gurus4 years ago

We used a max heap. This heap uses the distance from the origin as the comparison operator. From code:

def lt(self, other): return self.distance_from_origin() > other.distance_from_origin()

This means the heap keeps the farthest point at the top. We compare other...

V
K
k 3 years ago

.