Find the element that appears once
Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity… Read More »
Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity… Read More »
Given two signed integers, write a function that returns true if the signs of given integers are different, otherwise false. For example, the function should… Read More »
Given a positive integer n, count the total number of set bits in binary representation of all numbers from 1 to n. Examples: Input: n… Read More »
In computer science and mathematics, the Josephus Problem (or Josephus permutation) is a theoretical problem. Following is the problem statement: There are n people standing… Read More »
Given a number x and two positions (from the right side) in the binary representation of x, write a function that swaps n bits at… Read More »
Write a function Add() that returns sum of two integers. The function should not use any of the arithmetic operators (+, ++, –, -, ..… Read More »
Write a program to find the smallest of three integers, without using any of the comparison operators. Let 3 input numbers be x, y and… Read More »
Input: A array arr[] of two elements having value 0 and 1 Output: Make both elements 0. Specifications: Following are the specifications to follow. 1)… Read More »
Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array? The simple approach would be, create… Read More »
Given a number x, find next number with same number of 1 bits in it’s binary representation. For example, consider x = 12, whose binary… Read More »
Modulus operator is costly. The modulus operator (%) in various languages is costly operation. Ultimately every operator/operation must result in processor instructions. Some processors won’t… Read More »
Write a program to add one to a given number. The use of operators like ‘+’, ‘-‘, ‘*’, ‘/’, ‘++’, ‘–‘ …etc are not allowed.… Read More »
Given a integer x, write a function that multiplies x with 3.5 and returns the integer result. You are not allowed to use %, /,… Read More »
Write a program that unsets the rightmost set bit of an integer. Examples : Input: 12 (00…01100) Output: 8 (00…01000) Input: 7 (00…00111) Output: 6… Read More »
Given an integer n, find whether it is a power of 4 or not. Example : Input : 16 Output : 16 is a power… Read More »