When we see this title, the first thing we think of is looping through one of the arrays and judging whether each element in the array appears in another array, so as to determine whether the array is a subset of another array. However, doing this is too complicated. Is there a simple way?
For example, there are two sets like this:
string[] smallArr = new string[] { "a", "b"};
Now we need to determine whether smallArr is a subset of bigArr. Just compare bigArr and smallArr and find the difference set. If the number of difference sets is greater than 0, it means that smallArr is a subset of bigArr.
var exceptArr = (smallArr);
//Judge whether it is a subset
if(())
{
("samllArr is a subset of bigArr");
}
else
{
("samllArr is not a subset of bigArr");
}
In the above method, we can only judge whether it is a subset, that is, the set element of the subset is always smaller than the large one.
Sometimes, there is also a need to determine whether bigArr contains smallArr, that is, smallArr can be a subset of bigArr, or it can be the same as bigArr.
if((t => (b => b==t)))
{
("samllArr is a subset or the same of bigArr");
}
else
{
("samllArr is not a subset or the same of bigArr");
}