Premium problem73. Unique Triangle Segments

Hard Locked

faces is a (m, 3) array of triangle vertex indices. Find the set of unique line segments composing all triangles. Return them as a sorted (k, 2) array (each segment sorted ascending, then unique rows).

Input

[[0 1 2]
 [1 2 3]
 [2 3 4]]

Output

[[0 1]
 [0 2]
 [1 2]
 [1 3]
 [2 3]
 [2 4]
 [3 4]]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)