Skip to content

Master Bit Manipulation For Coding Interviews

Bit Manipulation is a powerful technique that solves bit-related problems mostly in constant time.

Gopi Gorantala
Gopi Gorantala
3 min read
Bit Manipulation and tricks to ace coding interviews
Bit Manipulation and tricks to ace coding interviews

Table of Contents

Course Overview

In this course, you will learn how to solve problems using bit manipulation, a powerful technique that can be used to optimize your algorithmic and problem-solving skills.

This is one of the most important/critical topics when someone starts preparing for coding interviews for FAANG companies.

To kick things off, you’ll start by learning about the number system and how it’s represented. Then you’ll learn about the six bitwise operators: AND, OR, NOT, XOR, and bit shifting. Throughout, you will get tons of hands-on experience working through practice problems to help sharpen your understanding. By completing this course, you can solve problems faster and more efficiently.

What do you get?

  • 44 lessons were categorized based on topics.
  • 28 challenges.
  • 27+ Illustrations and sketches
  • 271 solutions provided.
  • Solutions are written in Java, Python, JavaScript, C++, and TypeScript.
  • GitHub repository access(Java, JavaScript)

Takeaway Skills

  1. Master problem-solving that involves bit manipulation.
  2. Master the bit manipulation allows you to organize all inputs in binary representation at the memory levels.
  3. Master how the bit-level operations are computed. Understand that bit-level operations are based on all the arithmetic operations built into all languages.
  4. Solve problems that are commonly asked in coding interviews related to bit manipulation.
  5. These bit tricks could help in competitive programming in running algorithms, mostly in O(1) time.

Est. Time: 5hrs to complete.

Course Contents

Getting Started

  1. Introduction to Bit Manipulation (preview)
  2. What is Bit Manipulation? (preview)

Number Systems, Bitwise, and Binary

  1. Introduction to Number Systems (preview)
  2. Decimal Number System (preview)
  3. Binary Number System and Representation (preview)
  4. What are Bitwise Operators? (preview)
  5. Count the Number of Digits in an integer (preview)
  6. Convert Decimal Numbers to Binary Numbers (preview)

Bitwise AND

  1. Introduction to AND Operator
  2. Bitwise And, Computations, and Examples
  3. Challenge 1: Count Set Bits Or Number of 1 bit's (preview)
  4. Solution Review: Count Set Bits Or Number of 1 bit's (preview)
  5. Counting Bits II
  6. Challenge 2: Check If a Given Number is Even/Odd
  7. Solution Review: Check If a Given Number is Even/Odd
  8. Challenge 3: Power of 2 (preview)
  9. Solution Review: Power of 2 (preview)

Bitwise OR

  1. Introduction to OR Operator
  2. Bitwise OR, Computations, and Examples
  3. Number Of Flips Required To Make a|b Equal to c

Bitwise NOT

  1. Introduction to NOT Operator
  2. Bitwise NOT, Computations, and Examples
  3. Switch Sign of a Number

Bitwise XOR

  1. Introduction to XOR
  2. Bitwise XOR, Computations, and Examples
  3. Swap Two Numbers
  4. Find Odd Occurring Element
  5. Detect If Two Integers Have Opposite Signs
  6. Hamming Distance
  7. Challenge 1: Single Number
  8. Solution Review: Single Number
  9. Challenge 2: Missing Number
  10. Solution Review: Missing Number

Bit Shifting - Left, Right

  1. Introduction to Bit Shifting
  2. Left Shifts
  3. Arithmetic and Logical Right Shifts

Bitwise Left Shift Problems

  1. Find the Bit Length of a Number
  2. Check If Kth Bit Is Set/Unset Using Left Shift
  3. Subsets Or Powerset (preview)
  4. Challenge 1: Get the First Set Bit Position Using the Left Shift
  5. Solution Review: Get The First Set Bit Position Using the Left Shift

Bitwise Right Shift problems

  1. Check If Kth Bit Is Set/Unset Using Right Shift
  2. Challenge 1: Get the First Set Bit Position Using the Right Shift
  3. Solution Review: Get the First Set Bit Position Using the Right Shift

Final Thoughts

This concludes the course on bit manipulation.

This course has taught you how to re-write arithmetic operators like +, -, /, * into left, right shift, and other bit-level operations.

I hope the learning you gained in this course will be useful in solving Leetcode, Hackerrank, HackerEarth, Codeforces, Codechef, and other online coding challenges. This will also help you with interviews at FAANG or other top tech companies.

I wish you good luck and hope this course makes a difference in your coding journey!

Note: In the upcoming edits, you will see the following items:
  1. Solutions in Rust and Go.
  2. A few medium and hard problems were asked in recent FAANG and fast-paced startup coding interviews.

Happy Coding 👨🏻‍💻 !!

If you have finished the course, I'm super happy for you 🥳, and it's been a pleasure to be part of your professional journey.

I'm working hard in my spare time to keep the site up and running and to update the site with the most requested features. So long as people are having fun, I want to keep the site going.

If you'd like to say thanks, I'd really appreciate a coffee :)

Buy Me A Coffee

Gopi Gorantala Twitter

Gopi has been a Full Stack(Java+React) since 2016. He worked in Europe, and India, from startups to tech giants. He has a strong engineering professional with a Bachelor's in Satellite Communications.