Graph Theory37 sections · 1633 units
Open in Course

Problem - Read Statement

(LeetCode 1584)

Read the problem statement. Note that the graph is implicit: you are not given edges. You need to generate all possible edges from the points. The cost between points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|.

With nn points, you have O(n2)O(n^2) edges total. That is a lot of edges for large inputs. Think about whether you need to generate all edges upfront or compute them on demand. This decision affects both time and space.