Find XOR of two numbers without using the XOR operator
Write a program to find the XOR of two numbers without using the XOR operator.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedWrite a program to find the XOR of two numbers without using the XOR operator.
Given an integer, compute its absolute value (abs) without branching.
This post will discuss some bit hacks/tricks on letters of the English alphabet. 1. Convert uppercase character to lowercase, 2. Convert lowercase character to uppercase, 3. Invert alphabet’s case, 4. Find a letter’s position in alphabet.
This post will discuss a few related problems related to unsetting the rightmost set bit of a number.
This post will discuss a few related problems that operate on the k’th bit of a number. 1. Turn off k’th bit in a number, 2. Turn on k’th bit in a number, 3. Check if k’th bit is set for a number, 4. Toggle the k’th bit.
In this post, we will see how to 1. Check if an integer is even or odd, 2. Detect if two integers have opposite signs or not, 3. Add one to an integer, 4. Swap two numbers without using any third variable.
Given two integers, x and n, where n is non-negative, efficiently compute the power function pow(x, n) using Divide & Conquer.
Given an array of n-1 distinct integers in the range of 1 to n, find the missing number in it in linear time.
Given a set S, generate all subsets of it, i.e., find the power set of set S. A power set of any set S is the set of all subsets of S, including the empty set and S itself.
Given two integers, swap them in a single line in Java.
This post will discuss how to determine whether two integers are equal without using comparison operators (==, !=, <, >, <=, >=) and arithmetic operators (+, -, *, /, %).
Write an algorithm to generate 0 and 1 with 75% and 25% probability, respectively, using a specified function that produces either 0 or 1 each with 50% probability.