Swap two bits at a given position in an integer
Given an integer, swap two bits at given positions in a binary representation of it.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an integer, swap two bits at given positions in a binary representation of it.
Given two integers, add their binary representation.
Given an integer array, duplicates are present in it in a way that all duplicates appear an even number of times except one which appears an odd number of times. Find that odd appearing element in linear time and without using any extra memory.
This post will discuss the XOR linked list, which is used to reduce memory requirements of doubly-linked lists using a bitwise XOR operator.
Given a number, check if it is a power of four or not.
Given a number, check if it is a power of 8 or not.
Given an integer, reverse its bits using binary operators.
Given an array having elements between 0 and 31, find elements that occur an odd number of times without using the extra space.
Huffman coding (also known as Huffman Encoding) is an algorithm for doing data compression, and it forms the basic idea behind file compression. This post talks about the fixed-length and variable-length encoding, uniquely decodable codes, prefix rules, and Huffman Tree construction.
Given an integer array with all its elements between 1 and n except two elements, which occur twice. Find two duplicate elements without using any extra memory in linear time.
Given a limited range array of size n and containing elements between 1 and n-1 with one element repeating, find the duplicate number in it without using any extra space.
Given a positive number n, efficiently generate binary numbers between 1 and n using the queue data structure in linear time.