← 返回 google 的题目列表Group Elements by Equality Function or Common Value
类型:online_judge
google
You are given a list of elements and a function that returns whether 2 elements are equal.
Return a list of all equal elements grouped together.
Now the function returns the same value for equal elements.
Example
Input
elements = [1, 2, 2, 3, 3, 3]
equal_func = lambda x, y: x == y