Fwd: [algogeeks] Interview Question

2016-06-07 Thread Tarun Sharma
See this amazing list here: http://www.writeulearn.com/interview-questions/ -- Forwarded message -- From: Umer Farooq Date: Fri, Apr 8, 2011 at 4:22 PM Subject: Re: [algogeeks] Interview Question To: algogeeks@googlegroups.com Ankur, you are rite. He mentioned that we may not

[algogeeks] Interview Question

2013-07-27 Thread enchantress
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 algogeeks+unsubscr...

Re: [algogeeks] Interview Question

2013-04-26 Thread Nishant Pandey
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 se

Re: [algogeeks] Interview Question

2013-04-26 Thread Krishnan
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 wrote: > Hi Nishant i did not understand the code can u please describe a bit > > Thanks > > > On Fri, Apr 19, 2

Re: [algogeeks] Interview Question

2013-04-19 Thread kartik n
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 wrote: > search the previous posts before posting > > search for > [algogeeks] Amazon Interview Question > you will get this > > -- > You received this message because you

Re: [algogeeks] Interview Question

2013-04-19 Thread rahul sharma
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 a

Re: [algogeeks] Interview Question

2013-04-19 Thread Nishant Pandey
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;iwrote: > 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 s

[algogeeks] Interview Question

2013-04-19 Thread Krishnan
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 Googl

[algogeeks] Interview question

2013-04-10 Thread rahul sharma
http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-rectangle-in-a-2d-matrix/ wat is complexity of thisn3 or mn2 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails fr

Re: [algogeeks] INTERVIEW QUESTION

2012-10-30 Thread Saurabh Kumar
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 wo

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread payal gupta
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 explaination

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread Saurabh Kumar
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, z(+-

Re: [algogeeks] INTERVIEW QUESTION

2012-10-27 Thread Saurabh Kumar
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 a

Re: [algogeeks] INTERVIEW QUESTION

2012-10-26 Thread payal gupta
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 imple

Re: [algogeeks] INTERVIEW QUESTION

2012-10-26 Thread Kartik Sachan
@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

Re: [algogeeks] INTERVIEW QUESTION

2012-10-26 Thread Raghavan
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 wrote: > >Given a cube with sides length n, write code to print all possible > paths from the center to the su

[algogeeks] INTERVIEW QUESTION

2012-10-26 Thread payal gupta
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 discu

[algogeeks] INTERVIEW QUESTION

2012-10-26 Thread payal gupta
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 d

[algogeeks] Interview Question

2012-08-12 Thread sahil taneja
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 discuss

[algogeeks] Interview Question - Probability

2012-08-12 Thread algo bard
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? --

Re: [algogeeks] Interview Question based on histogram

2012-05-17 Thread payal gupta
//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) { volpoured-=vcapacity-volarr[index]; volarr[index]=vcapacity; // if the height of t

Re: [algogeeks] Interview Question based on histogram

2012-05-17 Thread payal gupta
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 w

Re: [algogeeks] Interview Question based on histogram

2012-05-17 Thread Bhaskar Kushwaha
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 wrote: > Imagine that you have an histogram sto

Re: [algogeeks] Interview question

2011-11-29 Thread saurabh singh
@anup an example what the question meant if(x==1||x==0) { /*stuff*/ } On Wed, Nov 30, 2011 at 11:07 AM, Anup Ghatage 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 themselves. >

Re: [algogeeks] Interview question

2011-11-29 Thread Anup Ghatage
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 wrote: > *What a

[algogeeks] Interview question

2011-11-29 Thread Nitin Garg
*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 e

Re: [algogeeks] Interview question

2011-10-31 Thread shady
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 o

Re: [algogeeks] interview question

2011-07-20 Thread surender sanke
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 wrote: > here T becomes char *.. u r trying to add two addreses

Re: [algogeeks] interview question

2011-07-19 Thread Anika Jain
here T becomes char *.. u r trying to add two addreses here... On Tue, Jul 19, 2011 at 9:46 PM, nidhi jain wrote: > Consider a c++ template funtion > template > 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 t

[algogeeks] interview question

2011-07-19 Thread nidhi jain
Consider a c++ template funtion template 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 Group

[algogeeks] Interview question

2011-07-09 Thread Gopi
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 arra

[algogeeks] Interview Question

2011-07-02 Thread mittal
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

Re: [algogeeks] Interview Question: Puzzle: Probability

2011-06-22 Thread Vishal Jain
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 m

Re: [algogeeks] Interview Question: Puzzle: Probability

2011-06-14 Thread Navneet Gupta
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 wrote: > Folks, > > This question was asked during a screening process of a product based > company. Please answer. > > http://exploreriddles.b

[algogeeks] Interview Question: Puzzle: Probability

2011-06-14 Thread Vishal Jain
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 en

Re: [algogeeks] Interview Question

2011-04-11 Thread Umer Farooq
Ankur, you are rite. He mentioned that we may not know what the data might be. And yes, I agree that he kept the restriction because we may not know what the data is. In that case, I guess bit by bit copying of data from the next node to the current node (it is possible since both the nodes are of

Re: [algogeeks] Interview Question

2011-04-08 Thread ankur bhardwaj
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, y

Re: [algogeeks] Interview Question

2011-04-07 Thread Abhishek Mallick
@ your name last name : please read the question carefully. * * * * On Fri, Apr 8, 2011 at 12:11 AM, your name last name wrote: > 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

Re: [algogeeks] Interview Question

2011-04-07 Thread your name last name
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 be

Re: [algogeeks] Interview Question

2011-04-07 Thread Anurag atri
@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 wrote: > lets say there are two pointers - temp1,temp2 and the start of the node is > head > now, > tem

Re: [algogeeks] Interview Question

2011-04-07 Thread balaji a
lets say there are two pointers - temp1,temp2 and the start of the node is head now, temp1=head; temp2=head->next; temp1->next=temp2->next; now temp1 points to the first node and the temp2 points to the second node(which got deleted from the list). On Thu, Apr 7, 2011 at 5:43 PM, U

Re: [algogeeks] Interview Question

2011-04-07 Thread Kamakshii Aggarwal
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 wrote: > Hello friends, > > The following question has appeared in two top companies of my city. I'd >

Re: [algogeeks] Interview Question

2011-04-07 Thread Umer Farooq
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 wrote: > @akash ur rite u cannot move data there > > > On Thu, Apr 7, 2011 at 2:35 PM, Akash Mukherjee wrot

Re: [algogeeks] Interview Question

2011-04-07 Thread Umer Farooq
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 wrote: > in case you are giv

Re: [algogeeks] Interview Question

2011-04-07 Thread Kamakshii Aggarwal
@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 wrote: > in case you are given a pointer to the first node simply do > temp ->next = ( temp -> next ) -> next . > i

Re: [algogeeks] Interview Question

2011-04-07 Thread Umer Farooq
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 wrote: > @ anurag > > temp -> data = ( temp -> next ) -> data ; > > but data cannot be moved, ryt?? > > On 4/6/11, Anurag atri wr

Re: [algogeeks] Interview Question

2011-04-07 Thread Abdul Rahman Shariff
@akash ur rite u cannot move data there On Thu, Apr 7, 2011 at 2:35 PM, Akash Mukherjee wrote: > @ anurag > > temp -> data = ( temp -> next ) -> data ; > > but data cannot be moved, ryt?? > > On 4/6/11, Anurag atri wrote: > > in case you are given a pointer to the first node simply do > > temp

Re: [algogeeks] Interview Question

2011-04-07 Thread Akash Mukherjee
@ anurag temp -> data = ( temp -> next ) -> data ; but data cannot be moved, ryt?? On 4/6/11, Anurag atri 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 -> data = ( temp

Re: [algogeeks] Interview Question

2011-04-06 Thread Anurag atri
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 wrote: >

[algogeeks] Interview Question

2011-04-06 Thread Umer Farooq
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

Re: [algogeeks] Interview question amazon

2011-01-15 Thread Ashish Goel
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->righ

Re: [algogeeks] Interview Question

2011-01-11 Thread juver++
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 algogeeks+unsubscr...@googlegroups

Re: [algogeeks] Interview Question

2011-01-11 Thread Vikas Singh
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++ wrote: > If you represent dictionary as a hash table, lookup costs you O(L) at > least! > Cause you need to calculate hash for the strin

Re: [algogeeks] Interview Question

2011-01-11 Thread juver++
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,

Re: [algogeeks] Interview Question

2011-01-11 Thread manoj lalavat
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++ wrote: > What do you mean by N? > If N - size of the dictionary. And L- maximum length o

Re: [algogeeks] Interview Question

2011-01-11 Thread juver++
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 unsubscrib

Re: [algogeeks] Interview Question

2011-01-11 Thread manoj lalavat
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 P

Re: [algogeeks] Interview Question

2011-01-11 Thread Vikas Singh
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++ wrote: > 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 mes

Re: [algogeeks] Interview Question

2011-01-11 Thread Vikas Singh
please ignore earlier message...it was supposed to be a private message.. On Tue, Jan 11, 2011 at 6:52 PM, Vikas Singh wrote: > lalla..bruteforce na bako.. :P > > > On Tue, Jan 11, 2011 at 6:07 PM, manoj lalavat wrote: > >> you can optimize BF >> >> newspaper >> >> first word you will search >> >

Re: [algogeeks] Interview Question

2011-01-11 Thread Vikas Singh
lalla..bruteforce na bako.. :P On Tue, Jan 11, 2011 at 6:07 PM, manoj lalavat wrote: > 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

Re: [algogeeks] Interview Question

2011-01-11 Thread juver++
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

Re: [algogeeks] Interview Question

2011-01-11 Thread manoj lalavat
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 Si

[algogeeks] Interview Question

2011-01-11 Thread Vikas Singh
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 subscri

Re: [algogeeks] Interview question amazon

2011-01-04 Thread ADITYA KUMAR
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 r

Re: [algogeeks] Interview question amazon

2010-12-27 Thread mohit ranjan
any hint for below question ? Mohit On Sun, Dec 26, 2010 at 10:38 PM, MAC wrote: > you are given a bst where each node has a int value , parent pointer , and > left and right pointers , write a function to find a path with a given sum > value. Path can go from left subtree tree , include roo

[algogeeks] Interview question amazon

2010-12-26 Thread MAC
you are given a bst where each node has a int value , parent pointer , and left and right pointers , write a function to find a path with a given sum value. Path can go from left subtree tree , include root and go to right tree as well . we need to find these paths also .

[algogeeks] Interview question

2010-12-24 Thread MAC
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 subscrib

[algogeeks] interview-question

2010-08-03 Thread jalaj jaiswal
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 evalu

Re: [algogeeks] interview question

2009-11-04 Thread daizi sheng
I guess this is just a *program* problem, not even including any algorithm problem. Even from viewer of c++ programmer, I think you should refer any classic c++ tutorial for it, instead of asking it online. It is an interview problem, and it can be find on any c++ book. Just use some time to find i

[algogeeks] interview question

2009-11-04 Thread yash
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 cla

[algogeeks] Interview question: can this be done?

2006-02-14 Thread Kevin
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 th