Say we have a list of a list of integers. What that would look like is [list1, list2, list3], basically List<List>. Then assume we have the master list masterList which is just List. Is there a way to check each list in List<List> and for each value in each list, if the value, or item, is in the master list, then leave as is, but if it is not in the master list then there should be a "(N/A)" next to it. So example:
List<Integer> masterList = Arrays.asList(122, 123, 124, 155, 621, 982);
List<Integer> list1 = Arrays.asList(122, 124, 155, 331, 982);
List<Integer> list2 = Arrays.asList(122, 124, 444);
List<Integer> list3 = Arrays.asList(2, 122, 123, 124, 133, 155, 332, 621, 667, 982);
// I guess each list could be on its own, but for my purposes the lists are in a list, so:
List<List<Integer>> lists = new ArrayList<>();
lists.add(list1);
lists.add(list2);
lists.add(list3);
So if we were to compare each list in lists to the masterList, then the end result should be a list of lists but each list will have updated values indicating if they are in the master list or not, so for pseudo-code ease sakes:
list1 = [122, 124, 155, 331(#N/A), 982(#N/A)]
list2 = [122, 124, 444(#N/A)]
list3 = [2(#N/A), 122, 123, 124, 133(#N/A), 155, 332(#N/A), 621(#N/A), 667(#N/A), 982(#N/A)]
and then I guess they would all be in lists again, so, lists.add(list1, list2, list3).
I tried coding this but failed, and some solutions i tried coming up with had really bad time/space complexity. It's assumed that every list involved is sorted, unique, and does not have to be the same size.
It is necessary that the original list is of Integer type so it could be sorted, but I know that in the end there needs to be a new list holding 3 new lists that in the end are of String type, not Integer type anymore. This is sort of like comparing 3 columns to 1 column using VLOOKUP in Excel. If anyone could help out with a solution, you have my blessings!! Thank you!