Woodstock Blog

a tech blog for general algorithmic interview questions

[Question] Check String With No Common Letters (Bitmask)


RT. This is a very very common requirements in the area of string manipulation. We want it to be done very efficiently.


Normally, we would use a hashmap. However, we can also use bitmask or bitmap.

Work for a-z only, we use 1 integer to represent each letter, and set an integer for each string.

We do (mask1 & mask2 == 0) to find no common letters. Read more at this question, [Google] Max prodcut of strings that have no common char.