Segments of tape are laid on a line; segment [a, b] is closed. A segment is hidden when some other segment contains it entirely and is not identical to it: there is a segment [c, d] with c <= a, b <= d and (c, d) != (a, b). Two identical segments never hide each other. Return how many segments are not hidden.
Examples
Input: segments = [[1, 4], [2, 3], [3, 6], [2, 3], [0, 1]]
Output: 3
Explanation: Both copies of [2, 3] are hidden by [1, 4]; the other three remain visible.
Input: segments = [[1, 5], [1, 5]]
Output: 2
Constraints
0 <= len(segments) <= 5 * 10**4,0 <= a <= b <= 10**9.- Target complexity: O(n log n).
Goals
- Pick a sort order (start ascending, end descending) that makes containment a one-sided test
- Handle identical segments consistently