Within a Solidity Smart Contract, I have 2 arrays that need to be compared. I would like the output to be 3 different arrays that can be used for other logic within the contract.
Example of the arrays:
contract myLists {
string[5] public listOne = ['AAA','BBB','CCC','DDD','EEE'];
string[5] public listTwo = ['AAA','BBB','DDD','FFF','GGG'];
}
The outputs should be:
#Output 1: items in listTwo that do not exist in listOne
string[] public output1['FFF','GGG']
#Output 2: items in listTwo that exist in listOne
string[] public output2['AAA','BBB','DDD']
#Output 3: items in listOne that do not exist in listTwo
string[] public output3['CCC','EEE']
From all my research, it seems array functionality is quite limited in Solidity and the only way may be a for loop.
What is the most gas efficient way to achieve this with arrays. Alternatively, is there a more efficient approach using a different method of storage e.g. Structs?
Thanks.