I have two lists of strings List A and B.Lists might have same length or maybe one is longer than the other.There's no duplicate values in each list.They consist of random numbers.
What I want to do is to find the missing and the extra element exists in A compared to list B.And save them in two new lists , one for missing elements and one for extra elements.
For Example :
A = ["3000047" , "3000042" , "3000030" , "30000475"]
B = ["3000047" , "3000043" , "3000030" ]
The output should be
Missing = ["3000043"]
Extra = ["3000042" , "30000475"]
I think of doing at as below. But not sure about the performance and its efficiency.
- Read element from A.
- Check if element exists in B.
- If no add it to Extra list.
- If yes remove the element from both A and B.
- If B is empty add all renaming elements in Extra list.
- If A is empty add all renaming elements in Missing list.