且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除二维数组中无序重复项最省时的方法是什么?

更新时间:2021-08-14 09:26:13

既然你想找到无序的重复,***的方法是通过类型转换.Typecast 它们为 set.因为 set 只包含 immutable 元素.所以,我做了一组tuples.

Since you want to find unordered duplicates the best way to go is by typecasting. Typecast them as set. Since set only contains immutable elements. So, I made a set of tuples.

注意:消除重复的***方法是对给定元素进行set.

Note: The best way to eliminate duplicates is by making a set of the given elements.

>>> set(map(tuple,map(sorted,x)))
{(-3, -2, 4, 5), (-5, 0, 4, 5)}