Last Updated: February 25, 2016
·
210
· shouya

Use an Array as a set

Intersection of two arrays:

arr1 & arr2

Union:

arr1 | arr2

Remove all elements in arr2 from arr1, kinda like flags & ~FLAG_XXX in C:

arr2 - arr1

In addition, by combining with assignment you can get

arr1 &= arr2
arr1 |= arr2
arr1 -= arr2

works well.