##
Count set bits in an integer
August 19, 2009

Write an efficient program to count number of 1s in binary representation of an integer. Examples Input : n = 6 Output : 2 Binary… Read More »

August 19, 2009

Write an efficient program to count number of 1s in binary representation of an integer. Examples Input : n = 6 Output : 2 Binary… Read More »

August 15, 2009

An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array… Read More »

August 8, 2009

Asked by Anshya. Below are the different ways to add base 14 numbers.

August 6, 2009

Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers,

August 2, 2009

Given an unsigned integer, reverse all bits of it and return the number with reversed bits. Input : n = 1 Output : 2147483648 On… Read More »

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with… Read More »

July 16, 2009

What are these? Little and big endian are two ways of storing multibyte data-types ( int, float, etc). In little endian machines, last byte of… Read More »

July 11, 2009

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12,… Read More »

June 29, 2009

Write a “C” function, int addOvf(int* result, int a, int b) If there is no overflow, the function places the resultant = sum a+b in… Read More »

June 22, 2009

The eight queens problem is the problem of placing eight queens on an 8×8 chessboard such that none of them attack one another (no two… Read More »

Power Set Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then… Read More »

You are given a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in list.… Read More »

Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number… Read More »

June 19, 2009

Write a one line C function to return position of first 1 from right to left, in binary representation of an Integer. I/P 18, Binary… Read More »