- Power of two: if (n & (n-1) == 0) then n is a power of two
- Odd or even: if (n & 1 == 0) then n is even
- Set nth bit of number i to 1: i | (1 << n)
- Set nth bit of number i to 0: i & ~(1 << n )
This blog contains stuff that I don't want to forget but might be useful to someone else too. Posts are short and to the point with enough detail for future me to make sense of.
Subscribe to:
Post Comments (Atom)
Scala with Cats: Answers to revision questions
I'm studying the 'Scala with Cats' book. I want the information to stick so I am applying a technique from 'Ultralearning...
-
Ansible is a great tool for config management on a set of remote machines. However, Ansible can be used to execute commands locally too. M...
-
The Question: You have to climb up a ladder. The ladder has exactly N rungs, numbered from 1 to N. With each step, you can ascend b...
-
Tree: 3 5 2 1 4 6 Preorder Traversal root -> left subtree -> right subtree 3 -> 5 -> ...
No comments:
Post a Comment