I want to detect a duplicate in a list of list. For example
[[-1,0,-1][0,1,2][0,-1,-1]]
By duplicate, I meant if a list contains the same elements in any order.
I tried one solution which is to sort the list and insert each of them into the set. Is there any other better way to do it?
One problem I faced is, if I insert the list as it is without sorting, into a set, It'll not be detected as a duplicate. (i.e [-1,0,-1] and [0,-1,-1])
Finally how I want the list is,
[[-1,0,-1][0,1,2]]
Please note that the same question is answered here Java: Best way to remove duplicated list in a list, but it is slightly different than what I am asking here.