You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Therefore, we need to maintain a list of the **last y-coordinate of the current chain**.
24
+
23
25
1.**Sort the points**: Sort them by increasing x coordinates.
24
26
2.**Initialization**: Create an empty list `last_y` to store the last y-coordinate of each chain.
25
27
3.**Traverse the set of points**:
26
-
- For each point (x, y):
27
-
- Use `bisect_right` to find the first position in `last_y` that is greater than the current y.
28
-
- If the index is less than the length of `last_y`, it means there is an existing chain that can accommodate the current point, so we update the last y-coordinate of that chain to the current y.
29
-
- If the index is equal to the length of `last_y`, it means no suitable chain is found, so we need to create a new chain and add the current y to `last_y`.
28
+
- For each point (x, y):
29
+
- Use `bisect_right` to find the first position in `last_y` that is greater than the current y.
30
+
- If the index is less than the length of `last_y`, it means there is an existing chain that can accommodate the current point, so we update the last y-coordinate of that chain to the current y.
31
+
- If the index is equal to the length of `last_y`, it means no suitable chain is found, so we need to create a new chain and add the current y to `last_y`.
0 commit comments