This post contains a collection of problems that I’ve solved using bitwise operators in Go. I’ll be trying to keep the examples as practical as possible. I plan to continue updating this post as I find more examples to share with you-all.
Bitwise Operators
Go provides operators that perform bitwise logical and bit shift operations on integer types.
The bitwise logical operators are:
& bitwise AND
| bitwise OR
^ bitwise XOR
&^ bit clear (AND NOT)
The bit shift operators are:
<< left shift integer << unsigned integer
>> right shift integer >> unsigned integer
String contains unique lowercase alphabet characters
This function uses bitwise operators << (left shift)
, & (AND)
, and | (OR)
to tell if a string contains
all unique lowercase alphabet characters.