## Number Complement Leetcode Solution

Problem Statement In this problem, we are given a decimal number. The goal is to find its complement. Example N = 15 0 N = 5 2 Approach (Flipping bit by bit) We can flip every bit in the integer ‘N’ to get its complement. The important part is, we …

## Hamming Distance Leetcode Solution

Problem Statement In this problem, we are given two integers, A and B, and the goal is to find the hamming distance between the given integers. The integers are greater that/equal to 0 and less than 231    Example First Integer = 5 , Second Integer = 2 3 First Integer …

## Power of Two Leetcode Solution

We are given an integer and the goal is to check whether the integer is a power of two, that is, it can be represented as some whole power of ‘2‘. Example 16 Yes 13 No Approach A trivial solution can be: Check if all prime factors of the integer …

## XOR Operation in an Array Leetcode Solution

Problem Statement In this problem we have to do XOR Operation in an Array of size n in which each element is equal to (start + 2*i) where i is the index of the element (0-indexed) and value of start is given. We have to return the bitwise XOR of …

## Find number of pairs in an array such that their XOR is 0

The problem “Find number of pairs in an array such that their XOR is 0” state that supposes, we have given an array of integers. The problem statement asks to find out the number of pairs present in an array, which has the pair Ai XOR Aj = 0. Note: …

## Check in binary array the number represented by a subarray is odd or even

The problem “Check in binary array the number represented by a subarray is odd or even” states that you are given a binary array and a range. The array consists of the number in the form of 0s and 1s. The problem statement asks to find out the number represented …

## Queries on XOR of greatest odd divisor of the range

Problem Statement The problem “Queries on XOR of greatest odd divisor of the range” states that you are given an array of integer and query q, each query consists of a range. The problem statement asks to find out the XOR of the greatest odd divisor within the given range …

## Queries for counts of array elements with values in given range

Problem Statement The problem “Queries for counts of array elements with values in given range” states that you have an integer array and two number x and y. The problem statement asks to find out the count of numbers present in array that lies between the given x and y. …

## Subset Leetcode

In Subset Leetcode problem we have given a set of distinct integers, nums, print all subsets (the power set). Note: The solution set must not contain duplicate subsets. An array A is a subset of an array B if a can be obtained from B by deleting some (possibly, zero …

## Reverse Bits

Reverse bits of a given 32 bits unsigned integer. Example Input 43261596  (00000010100101000001111010011100) Output 964176192 (00111001011110000010100101000000) A 32-bit unsigned integer refers to a nonnegative number which can be represented with a string of 32 characters where each character can be either ‘0’ or ‘1’. Algorithm for i in range 0 …

Translate »