Java – bit strings: check whether one bitstring is a subset of another

I represent this group of English letters as a 26 bit string The first bit corresponds to 'a', the setting bit corresponds to 'B', and so on

Solution

If you do use only 26 bits, you can use an integer (32 bits) to represent the bit set and use the bitwise and (&) operator to get the intersection in the two groups

If & B = = a, a is a subset of B

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>