Skip to content

Gopi Gorantala

I'm Gopi — 15+ years in Java, building Kafka and Flink platforms for banks, where one lost event is a financial discrepancy. I write javahandbook.com because the guides I needed didn't exist. Everything here is tested against a real cluster first.

Members only

Challenge 1: Single Number

In this lesson, every element appears twice except one element. We solve this using naive, and then we move to solve it more optimally using XOR operator.

Members only

Hamming Distance

Hamming distance talks about two integers where the bit positions where the corresponding bits are different.

Members only

Detect If Two Integers Have Opposite Signs

In this question, input two numbers and detect if they have opposite signs. We solve using bitwise XOR operator

Members only

Find Odd Occurring Element

In this coding question, we find the odd-appearing element using bitwise xor. This algorithm is simple yet powerful.

Members only

Swap Two Numbers

In this coding question, we input two numbers and swap them without using the swapping logic.

Members only

Bitwise XOR, Computations, and Examples

A Bitwise XOR is a binary operation that takes two-bit patterns of equal length and performs the logical exclusive OR operation on each corresponding bits pair. Each position’s result is 0 if both bits are 0 or if both bits are 1. Otherwise, the result is 1.

Members only

Introduction to XOR

The Bitwise XOR operator is denoted by ^. When an XOR gate is given with 2 inputs, the corresponding outputs will be: If two input bits are different, the output is 1. In all other cases, it is 0.

Members only

Solution Review: Power of 2

Let's solve this using brain kernighan's algorithm. This is optimized to O(1) time and space.

Members only

Solution Review: Check If a Given Number is Even/Odd

This is a solution to another Bitwise question. Think of the rightmost bit of a number and think of some logic that could solve this. We solve using AND operator with O(1) time Complexity.

Members only

Solution Review: Count Set Bits Or Number of 1 bit's

We saw an algorithm to solve this problem in the previous lesson. Let’s see how to solve this more efficiently using Briann’s Algorithm. This is a faster execution than the previous naive approach.