void main() {
List<int> x = [1,4,3,6];
List<int> y = [3,6,9,10,2];
var List<int> output = [];
print(output);
}
CodePudding user response:
I don't know what exactly "unique numbers" mean in your context.
I guest "unique numbers" from list x an y mean the numbers which are in x or in y.
Example: x = [1, 2, 3]
, y = [2, 3, 4]
, the output is [1, 2, 3, 4]
or x = [3, 4, 5]
and y = [5, 6, 7]
=> ouput = [3, 4, 5, 6, 7]
If this is the result you want to archive, you can consider following code:
void main() {
List<int> x = [1,4,3,6];
List<int> y = [3,6,9,10,2];
List<int> output = x.toSet().union(y.toSet()).toList();
print(output);
}
output:
[1, 4, 3, 6, 9, 10, 2]
CodePudding user response:
I am javascript developer but that would help you
Var uniqueArray =list1.filter(function(obj){return list2.indexOf(obj)== -1;})