Puzzle CornerSign In
HomeFeedbackBlogResourcesAbout
Starred
Add Question
All (696)
coding (266)
c++ (157)
algorithms (151)
puzzle (134)
CS Fundamentals (83)
oop (55)
arrays (45)
internet (40)
string (34)
math (31)
databases (28)
system (26)
probability (26)
networking (25)
linkedlist (24)
binarytrees (24)
tree (22)
bit manipulation (19)
sorting (11)
stack (10)
bst (9)
java (8)
xml (8)
sql (7)
next in series (7)
traversal (6)
graph (4)
debugging (4)
lateral thinking (4)
palindrome (4)
mysql (4)
prime (4)
general (4)
unix (3)
CGI (3)
duplication (3)
threading (3)
random (3)
search (3)
fibonacci (3)
encryption (3)
joins (3)
hash (3)
queue (3)
asm (3)
design patterns (2)

next »

Random
Whats the difference?[2007-02-26 23:42:21]   
What is the difference between static_cast(*this) += 5; and static_cast(*this) += 5;?
linkAuthor:premTags: c++1 CommentAnswer

Fork in the road[2007-02-26 23:42:16]   
You are ill and travelling down a road to the hospital. You reach a fork
in the road and find a pair of identical twin boys standing there. One
of the twins always tells the truth and the other twin always lies. You
are allowed to direct only one question to one of the twins, and as such
you will be assured of the correct road to the hospital. What is your
question and to whom?
linkAuthor:premTags: puzzle1 CommentAnswer

Multiplication of numbers[2008-06-16 04:56:01]   
There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n).
linkAuthor:sudhaTags: puzzle | arrays | math8 CommentsAnswer

Return unique elements in an array[2007-02-26 23:42:19]   
Implement an algorithm to take an array and return one with only unique elements in it.
linkAuthor:premTags: algorithms | arrays3 CommentsAnswer

Array left rotation[2007-02-26 23:42:19]   
Rotate an n-element vector left by i positions in time proportional to n with just a dozen bytes of extra space. For instance, with n=8 and i=3, the vector abcdefgh is rotated to defghabc
linkAuthor:premTags: arrays2 CommentsAnswer

Array duplication problem[2007-02-26 23:42:17]   
Given an array of length N containing integers between 1 and N,
determine if it contains any duplicates.
linkAuthor:premTags: arrays | duplication6 CommentsAnswer

Majority element[2007-02-26 23:42:22]   
A majority element in an array A, of size N is an element that appears more than N/2 times (and hence there is atmost
one such element)

Write a function which takes an array and emits the majority element (if it exists), otherwise prints NONE as follows:

I/P : 3 3 4 2 4 4 2 4 4
O/P : 4

I/P : 3 3 4 2 4 4 2 4
O/P : NONE
linkAuthor:premTags: algorithms | coding | arrays2 CommentsAnswer

Sorting colored arrays[2007-02-26 23:42:22]   
Say we have a data structure as follows:

enum {RED,BLUE,GREEN};
struct Ball
{
/*...*/
int color;
};

int ColorOfBall(Ball b)
{
return b.color;
}
Ball arr[SIZE];

The array arr consists of balls of with one of the three colours
(Red,Green,Blue). Now we need to sort the array in such a way that all
the Red coloured balls come first, followed by blue and then green.

The restriction is that call to function ColorOfBall is a very costly
operation. You have to use it as less as possible. (In other words we
would be looking for the solution with least number of calls to the
function ColorOfBall.)
linkAuthor:premTags: algorithms | coding | arrays2 CommentsAnswer

Array merge problem[2007-02-26 23:42:17]   
You have two sorted integer arrays and the larger array has room for the
second. Merge the smaller array into the larger one, in O(n) time and
O(1) space.
linkAuthor:premTags: algorithms | coding | arrays1 CommentAnswer

Sum it up[2007-02-26 23:42:18]   
You are given a sequence of numbers from 1 to n-1 with one of the numbers repeating only once. (example: 1 2 3 3 4 5). how can you find the repeating number? what if i give you the constraint that you can't use a dynamic amount of memory (i.e. the amount of memory you use can't be related to n)?
what if there are two repeating numbers (and the same memory constraint?)
linkAuthor:premTags: coding | arrays2 CommentsAnswer

Array subset with sum closest to zero[2007-02-26 23:42:19]   
Given an array, Design an algorithm to find the subvector with the sum closest to zero.
extenstion: What if we wished to find teh subvector with the sum closest to a given real number t?
linkAuthor:premTags: algorithms | arraysAnswer

Find missing number[2007-02-26 23:42:18]   
Given a consecutive list of numbers from a to b, one number is removed.
The list is then scrambled. Find the missing number.
int find(int a, int b, int *array);
hint: sum(1 to n) is n(n+1)/2
using the same logic, sum(a to b) is (b-a)/2 * (b+a)
linkAuthor:premTags: algorithms | arraysAnswer


next »




Created by Premchand Jayamohan