I have an ordered list A and a string set B in Java. I need the comparision output to be in the form of a binary array. For example if A was {a,b,c,d,e} and B was {a,d,e}, my output should be an array [1,0,0,1,1]. How can i achieve this efficiently without resorting to brute force checking? I’m dealing with quite a large number of sets(large in size too) to compare with A.
I have an ordered list A and a string set B in Java. I
Share
What sort of sets are these? Normally sets don’t have any order.
It feels like essentially we need to treat
Bas a set butAas a list. For example, you might use:So long as the set implementation is a fast one (e.g.
HashSetorLinkedHashSet) this should be an O(n) operation where n is the size ofa. It’s hard to see how you could do significantly better given that you need to produce n results…