I am trying to find unique elements in a main list by comparing it with another list with a time complexity better than O(mn). Ex:-
listA, listB . I want to get unique elements only in listA and add to a new list.
Here is what I did
for (String item : listA) {
if (!listB.contains(item)) {
newList.add(item)
}
}
Here the time complexity is O(mn). Can anyone help me get to a better solution?