See this amazing list here:
http://www.writeulearn.com/interview-questions/
-- Forwarded message --
From: Umer Farooq <the.um...@gmail.com>
Date: Fri, Apr 8, 2011 at 4:22 PM
Subject: Re: [algogeeks] Interview Question
To: algogeeks@googlegroups.com
Ankur, you are rit
Given m*n matrix and k students how can they be placed such that cheatig is
minimised.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
an useful link
http://stackoverflow.com/questions/7338070/finding-an-element-in-an-array-where-every-element-is-repeated-odd-number-of-tim
On Fri, Apr 19, 2013 at 11:30 PM, kartik n kartik.car...@gmail.com wrote:
Hi Nishant i did not understand the code can u please describe a bit
Thanks
the code is simply utilizing the xor property as u know xor sets on odd one
so, if any array would have numbers odd times repeated
their bit will only stay in xor operation else will get nulify.
so in first loop bit of 1 and 3 are set, to seperate them we need to
divide them using any of their
In an array, some numbers occur only once, some numbers occur twice, only
one number occur thrice. Find the number occuring thrice ? Space complexity
O(1) Time Complexity O(n). We should not use Hash Maps.
Please someone help..
--
You received this message because you are subscribed to the
int main() {
int a[] = {1,2,2,3,3,3,4,4};
int size = sizeof(a)/sizeof(a[0]);
int xorr=0;
for(int i=0;isize;i++) {
xorr^=a[i];
}
int x=0,y=0;
int xor1=xorr ~(xorr-1);
for(int i=0;isize;i++) {
if(xor1 a[i]) x^=a[i];
else y^=a[i];
}
cout xy;
}
in this 1 and 3 would be output. as it
search the previous posts before posting
search for
[algogeeks] Amazon Interview Question
you will get this
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
Hi Nishant i did not understand the code can u please describe a bit
Thanks
On Fri, Apr 19, 2013 at 10:48 AM, rahul sharma rahul23111...@gmail.comwrote:
search the previous posts before posting
search for
[algogeeks] Amazon Interview Question
you will get this
--
You received this
you are right.
k is the edit distance we are searching for and a critical parameter. In
short you can say- k represents how much error(in terms of edit-distance)
you want to tolerate for between document word 'w' and your suggestion.
since our data structure can answer queries for e.g. Find all
could you please share the link? coz at first glance a Trie looks like a
bad choice for this task.
I'd go with the Levenshtein distance and a kd-tree.
First implement the Levenshtein distance algorithm to calculate the edit
distance of two strings.
Second, since Levenshtein distance qualifies as
Firstly, that question is missing a lot of details.
In absence of those details I'm going to make soem assumptions:
1. cube is odd lengthed, so that we can define a unique center of cube.
2. While traversing from a cell(x, y, z) we can only move into any of the 6
adjacent cells[x(+-)1, y(+-)1,
the question mentioned is as it isi just copy pasted it here.
@saurabh thanx for the explainaton of the cube problem i guess that is an
appropriate soln for the question.
and for the other question on detection of typos and suggestion i would
like to know to know what 'k' in your
Design the data structures and algorithms to detect typos in a document
and then provide suggestions to the user.
Thanx in advance,
Regards,
PAYAL GUPTA,
NIT-B.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
Given a cube with sides length n, write code to print all possible paths
from the center to the surface.
Thanx in advance.
Regards,
PAYAL GUPTA,
NIT-B.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
By any chance did you read the new blog post by Gayle Laakmaan..
I guess to detect typos we can use some sort of Trie implementation..
On Fri, Oct 26, 2012 at 7:50 PM, payal gupta gpt.pa...@gmail.com wrote:
Given a cube with sides length n, write code to print all possible
paths from the
@payal why u need this..??...:P:P
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more
Sorry ,posted the wrong question initially actually i needed the algo for
this question. Thanx.
On Saturday, October 27, 2012 7:04:10 AM UTC+5:30, raghavan wrote:
By any chance did you read the new blog post by Gayle Laakmaan..
I guess to detect typos we can use some sort of Trie
You are given n white balls in the beginning. Each day you pick up a ball
randomly, color it red and put it back. If it is already colored, you
simply put it back. This operation is performed for 'd' days. What is the
probability that after d days you will have greater than 'k' balls colored?
--
Divide 2D array into 4 parts. Compute sum of each partition and get max
value from the four of them. For all possible partitions get min value of
such max values computed.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
//A -area of the cell of histogram
// volarr[] -holds the vol of water already present at particular index
void fn(int index,int volpoured)
{
int vcapacity=A*heightarr[index];
if(volpoured+volarr[index]vcapacity)
{
volarr[index]+=volpoured;
return;
}
if(volpoured+volarr[index]vcapacity)
{
It depends on which column you are pouring the water.
For example
If you choose the shortest column to pour the water then only that column
will be filled with water.
Please correct me if I am wrong.
On Thu, May 17, 2012 at 11:27 AM, Nikhil Agarwal
nikhil.bhoja...@gmail.comwrote:
Imagine that
hope this works..
http://ideone.com/XSJRJ
On Fri, May 18, 2012 at 8:20 AM, Bhaskar Kushwaha
bhaskar.kushwaha2...@gmail.com wrote:
It depends on which column you are pouring the water.
For example
If you choose the shortest column to pour the water then only that column
will be filled with
*What are the different ways to say, the value of x can be either a 0 or a
1.*
--
Nitin Garg
Personality can open doors, but only Character can keep them open
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
If I have understood the question correctly, Infinite :P
You can have infinite ways to express 0 or 1 given that the ways are
differentiable amongst themselves.
An even number can be considered as a 0 and an odd number as a 1... etc
On Wed, Nov 30, 2011 at 8:37 AM, Nitin Garg
@anup an example what the question meant
if(x==1||x==0)
{
/*stuff*/
}
On Wed, Nov 30, 2011 at 11:07 AM, Anup Ghatage ghat...@gmail.com wrote:
If I have understood the question correctly, Infinite :P
You can have infinite ways to express 0 or 1 given that the ways are
differentiable amongst
from where does the index starts, 0 or 1 ? in this, array to be moved is
{7, 5, 8} ?
and source array the destination
| |
{9, 7, 5, 8, 1, 5, 4, 8, 10, 1}
please explain move_set
needs explicit function specialisation. be careful with constant strings.
T Add(T a, T b)
{return a+b ;}
template
char* Add char* a, char* b)
{return strcat((char*)a,b); }
surender
On Tue, Jul 19, 2011 at 10:17 PM, Anika Jain anika.jai...@gmail.com wrote:
here T becomes char *.. u r trying
Consider a c++ template funtion
templateclass T
T Add(T a, T b)
{return a+b ;}
if this function is called as T c = Add(SAM, SUNG); what will
happen? What is the problem in the template declaration/ How to solve
the problem.
--
You received this message because you are subscribed to the Google
here T becomes char *.. u r trying to add two addreses here...
On Tue, Jul 19, 2011 at 9:46 PM, nidhi jain nidhi.jain311...@gmail.comwrote:
Consider a c++ template funtion
templateclass T
T Add(T a, T b)
{return a+b ;}
if this function is called as T c = Add(SAM, SUNG); what will
happen?
Write code to move a set of elements (represented by start and end
indexed) in an array to a given destination location (denoted by
destination index).
For example:
Let say our array is {9, 7, 5, 8, 1, 5, 4, 8, 10, 1}
move_set (array, start = 1, end = 3, destination = 8)
should rearrage the
Given two arrays of numbers, find if each of the two arrays have the same
set of ntegers ? Suggest an algo which can run faster than NlogN without
extra space?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the
Navneet,
Your answer is correct, it would have been great if you could have explained
it for others.
I myself took good time to understand it...
Here is the answer
http://exploreriddles.blogspot.com/2011/06/interview-questions-puzzle.html
To maximize the chances of retrieving Red Ball, it is
Folks,
This question was asked during a screening process of a product based
company. Please answer.
http://exploreriddles.blogspot.com/2011/06/interview-questions-puzzle.html
Thanks Regards
Vishal Jain
Success taste better when target achieved is bigger.
P *We have a responsibility to the
Put one red ball in one jar and rest 99 balls in other jar.
Probability in that case is 1/2*1 + 1/2*49//99
On Tue, Jun 14, 2011 at 7:45 PM, Vishal Jain jainv...@gmail.com wrote:
Folks,
This question was asked during a screening process of a product based
company. Please answer.
For the 2nd ques, wat i think is the interviewer has kept the restriction of
not moving the data since you may have a linked list about which you donot
have much information about the structure of the node of the list(only know
about the next pointer) and hence you cannot move the data. For that,
@ anurag
temp - data = ( temp - next ) - data ;
but data cannot be moved, ryt??
On 4/6/11, Anurag atri anu.anurag@gmail.com wrote:
in case you are given a pointer to the first node simply do
temp -next = ( temp - next ) - next .
if you are given a pointer to the second node do ,
temp -
@akash ur rite u cannot move data there
On Thu, Apr 7, 2011 at 2:35 PM, Akash Mukherjee akash...@gmail.com wrote:
@ anurag
temp - data = ( temp - next ) - data ;
but data cannot be moved, ryt??
On 4/6/11, Anurag atri anu.anurag@gmail.com wrote:
in case you are given a pointer to the
So, is there any other way of doing this? I did it the way anurag did it;
but the interviewer asked me to do it without moving the data.
On Thu, Apr 7, 2011 at 6:38 PM, Abdul Rahman Shariff ears7...@gmail.comwrote:
@akash ur rite u cannot move data there
On Thu, Apr 7, 2011 at 2:35 PM, Akash
in the first case
temp -next = ( temp - next ) - next .
The middle node will become orphan and it won't be deleted, I guess.
in second case
I did it the same way. Then he asked me to solve this without moving the
data?
On Wed, Apr 6, 2011 at 8:03 PM, Anurag atri anu.anurag@gmail.comwrote:
@anurag:the second case of yours requires movement of data if I am not
wrong...
@umer farooq:pls calrify what does movement of data mean?
On Wed, Apr 6, 2011 at 8:33 PM, Anurag atri anu.anurag@gmail.comwrote:
in case you are given a pointer to the first node simply do
temp -next = ( temp -
That can be moved. Basically, he is trying to convey that move the data of
temp-next to temp. That's perfectly fine.
On Thu, Apr 7, 2011 at 2:05 PM, Akash Mukherjee akash...@gmail.com wrote:
@ anurag
temp - data = ( temp - next ) - data ;
but data cannot be moved, ryt??
On 4/6/11, Anurag
1st case:
if ptr points to the first node, then ptr-next=(ptr-next)-next will do.
2nd case:i think tehre has to be movement of data from third node to
the second node.
On 4/4/11, Umer Farooq the.um...@gmail.com wrote:
Hello friends,
The following question has appeared in two top companies of
@All
yeah my solution does move data ...
I am very interested in knowing a solution that moves no data , someone
please come up with a solution .
On Thu, Apr 7, 2011 at 9:23 PM, balaji a peshwa.bal...@gmail.com wrote:
lets say there are two pointers - temp1,temp2 and the start of the node is
Moving the data is unnecessary if in case the whole pointer shifting is
meant for the entire node and not for individual elements of the node.
temp -next = ( temp - next ) - next
the above statement is more than enough to remove the midlle node from the
list...
--
You received this message
@ your name last name : please read the question carefully.
*
*
*
*
On Fri, Apr 8, 2011 at 12:11 AM, your name last name ac08...@gmail.comwrote:
Moving the data is unnecessary if in case the whole pointer shifting is
meant for the entire node and not for individual elements of the node.
temp
Hello friends,
The following question has appeared in two top companies of my city. I'd
appreciate if anyone is able to answer it.
Given a singly liked list comprising of three nodes
Delete the middle node such that:
1- A temp pointer is pointing to the first node
2- A temp pointer is pointing
in case you are given a pointer to the first node simply do
temp -next = ( temp - next ) - next .
if you are given a pointer to the second node do ,
temp - data = ( temp - next ) - data ;
temp - next = NULL ;
correct me if I am wrong .
On Mon, Apr 4, 2011 at 9:48 PM, Umer Farooq
int hasPathSum(struct node* node, int sum) {
// return true if we run out of tree and sum==0
if (node == NULL) {
return(sum == 0);
}
else {
// otherwise check both subtrees
int subSum = sum - node-data;
return(hasPathSum(node-left, subSum) ||
hasPathSum(node-right,
Given a dictionary find out if given word can be made by two words in
dictionary. For eg. given newspaper you have to find if it can be made by
two words. (news and paper in this case). I cant think of anything but brute
force.
Thanks,
Vikas
--
You received this message because you are
you can optimize BF
newspaper
first word you will search
n
then
ne
then
new
then news..and so onif at any point of time first word exist in
dictionary then only see whether the word with the remaining characters
exist in the dictionary or not.
On Tue, Jan 11, 2011 at 5:57 PM, Vikas
Use trie (or similar DS).
For each word, try to find second part of the target in a linear time
O(length).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from
lalla..bruteforce na bako.. :P
On Tue, Jan 11, 2011 at 6:07 PM, manoj lalavat manoj.lala...@gmail.comwrote:
you can optimize BF
newspaper
first word you will search
n
then
ne
then
new
then news..and so onif at any point of time first word exist in
dictionary then only see
please ignore earlier message...it was supposed to be a private message..
On Tue, Jan 11, 2011 at 6:52 PM, Vikas Singh vikas.sing...@gmail.comwrote:
lalla..bruteforce na bako.. :P
On Tue, Jan 11, 2011 at 6:07 PM, manoj lalavat manoj.lala...@gmail.comwrote:
you can optimize BF
newspaper
Wouldn't that be O(n2) . what if n, ne, new, news, newsp etc all are valid
words ? Cant it be optimized?
On Tue, Jan 11, 2011 at 6:27 PM, juver++ avpostni...@gmail.com wrote:
Use trie (or similar DS).
For each word, try to find second part of the target in a linear time
O(length).
--
You
how abt this..
Pass1 = look whether words like n,ne,new,news.exist or not...store
information in some array like n is not found so is ne but new is found and
news is found so array will be like
0,0,1,1.
Pass2 = do d same from from the end...
r,er,per,aper,paper
0,0,1,0,1
What do you mean by N?
If N - size of the dictionary. And L- maximum length of the words then above
algo is O(N*L)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
words and...so on...
on dictionaries lookup is O(1) now think abt complexity...
pass1
for (1 to N) example here N=strlen(newspaper)
other passes are also same...
On Tue, Jan 11, 2011 at 8:07 PM, juver++ avpostni...@gmail.com wrote:
What do you mean by N?
If N - size of the dictionary. And
If you represent dictionary as a hash table, lookup costs you O(L) at least!
Cause you need to calculate hash for the string. But for the trie it is O(L)
in a worst case.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
I agree with the trie solution. But now how do you generalise it for K. I
mean a word can be made from k other words.
On Wed, Jan 12, 2011 at 12:53 AM, juver++ avpostni...@gmail.com wrote:
If you represent dictionary as a hash table, lookup costs you O(L) at
least!
Cause you need to calculate
This problem has DP solution in O(n^2) I think.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
problem has many properties like its a BST with parent pointer
we shud think of such a solution which uses its both property
If we will think abt the brute force recursive solution
its complexity will be O(no_of_nodes*height)
which can be made more efficient by putting some restrictions
in each
Given a Binary Matrix of 0's and 1's.
Write an algorithm to:
1) Print the largest Rectangular Sub-matrix with all 1's.
2)Print the largest Sub-matrix with all boundary elements 0.
Explain your whole algorithm with an example.
--
thanks
--mac
--
You received this message because you are
given a complete binary tree (either a node is a leaf node or has two
children)
every leaf node has value 0 or 1.
every internal node has value as the AND gate or OR gate.
you are given with the tree and a value V.
you have to output the minimum number of flips (AND to OR or OR to AND) if
the
write a program for catlog catlog contain subcatlog or product .
we can futher expand catlog/subcatalog. product is leaf of catalog
[like composite pattern]
1. write a c++ program to display the product on basis of product id.
write a copy constucter and assingement operator for catalog
Just back from an job interview, one question really sucks! Any idea?
It is given 45 mintues to state your thought (either how to do it, or
why you can not do it).
(Type from what I remember)
1) You choose 5000 different intergers (you can choose any 5000
integers you want to use, just be sure
65 matches
Mail list logo