[algogeeks] Re: Adobe Interview

2011-01-07 Thread Decipher
I think first we need to sort the boxes in decreasing order of height , width and length so that input like this (7,8,9),(5,6,8), (5,8,7),(4,4,4),(3,2,1),(9,9,10),(9,3,7) becomes (9,9,10),(9,3,7),(7,8,9),(5,8,7),(5,6,8),(4,4,4),(3,2,1) . Now we can apply DP here . Let dp[i] = maximum no. of boxes

[algogeeks] Re: Amazon Interview - Algorithms

2011-01-07 Thread juver++
Simple DP, dp[i] - minimum number of steps to reach position i. Then apply simple transitions: dp[i + step] = min(dp[i + step], dp[i] + 1), step = a[i]. Something in this way. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: Adobe Interview

2011-01-07 Thread Decipher
I think first we need to sort the boxes in decreasing order of volume so that input like this (7,8,9),(5,6,8),(5,8,7),(4,4,4),(3,2,1), (9,9,10),(9,3,7) becomes (9,9,10),(7,8,9),(5,8,7),(5,6,8),(9,3,7), (4,4,4),(3,2,1) . Now we can apply DP here . Let dp[i] = maximum no. of boxes fitting into each

[algogeeks] Re: Adobe Interview

2011-01-07 Thread juver++
You should try to rotate boxes also - to simplify this, sort all dimensions in ascending order. -- 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,

[algogeeks] Re: Google Interview Question

2011-01-07 Thread SM
Corrupted heap may be the case. On Jan 6, 8:38 pm, soundar soundha...@gmail.com wrote: Maybe the code has lot of dynamic updations..So for each kind of i/ p there can be different places where the updated value is used. -- You received this message because you are subscribed to the Google

[algogeeks] Re: Google Interview Question

2011-01-07 Thread bittu
After Spending Some Time To Analyze This Problem..I Got Its Non- Synchronization,Multi Threading Problem..Let Me Describe..- As The Source Program Build To Single Threaded Environment so When Multiple User Trying To Access The Same Part of Program at the same time ,its surely crashes..as Its Not

[algogeeks] Google Question

2011-01-07 Thread bittu
You have a stream of infinite queries (ie: real time Google search queries that people are entering). Describe how you would go about finding a good estimate of 1000 samples from this never ending set of data and then write code for it. Thanks Regards Shashank -- You received this message

[algogeeks] Re: Amazon Intrerview

2011-01-07 Thread bittu
They Indirectly Asked To Fine Lowest Comman Ancestor in BST... so The main idea of the solution is — While traversing BST from top to bottom, the first node y we encounter with value between x and z so if if Y lies between X and Z it means Y is LCA of X Z-- where XZ also true if above

[algogeeks] Re: Longest Palindrome

2011-01-07 Thread emacs ray
Manacher's algorithm does. I think it's a variant of Z algorithm. On Dec 31 2010, 5:10 am, Aniket aniket...@gmail.com wrote: How do you find the longest palindrome in a given string in O(n) time? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Google Interview Question

2011-01-07 Thread vaibhav agrawal
@Douglas, nicely put!!! On Fri, Jan 7, 2011 at 8:37 PM, Douglas Diniz dgdi...@gmail.com wrote: Some examples, supposing you do always the same thing: 1-) You have a program that use some random number, and based on the number the program do different things, and this different things crash

Re: [algogeeks] Re: Google Interview Question

2011-01-07 Thread Pedro Rezende
Hi all! And what could be the best way to test / debug issues like these? 2011/1/7 vaibhav agrawal agrvaib...@gmail.com @Douglas, nicely put!!! On Fri, Jan 7, 2011 at 8:37 PM, Douglas Diniz dgdi...@gmail.com wrote: Some examples, supposing you do always the same thing: 1-) You have a

Re: [algogeeks] Re: double and int

2011-01-07 Thread Avi Dullu
Thanx for the precise information. I was coming from a perspective of safe implementation, when dealing with variables, you might not always know whether the values to be compared will fall under the exact floating point representation, so the safe way to go might always be to use the 1.0e-5

[algogeeks] Re: Adobe Interview

2011-01-07 Thread Decipher
I think this is a modification of longest increasing subsequence problem . First , sort by length then find the longest increasing subsequence by width. Now, in this solution find longest increasing subsequence by height . This would be the answer to this question. -- You received this message

[algogeeks] Adobe - Coding

2011-01-07 Thread Decipher
Write a code that returns the 5 most common occuring strings in a list for example list would be something like a b c f a d e f b f f and the function would return f 4 a 2 b 2 c 1 d 1 I know the Count sort method . Just wanted to know is there any shorter method as count sort uses lots of space .

[algogeeks] Re: double and int

2011-01-07 Thread Dave
@Avi: Whether this is a safe implementation depends in part on whether you want to say that 0.2 == 0.29 because they differ by less than 1.0e-5, even though they differ by 45%. Applying your philosophical boilerplate, you have to use some intelligence even in this type of thing. Dave On

[algogeeks] Re: Adobe - Coding

2011-01-07 Thread juver++
As you work with strings, you cannot apply count sort here. Basic approach is to sort array, iterate over it and mantain ordered set of 5 items. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Adobe - Coding

2011-01-07 Thread Decipher
We can apply count sort here also and take the range of numbers as 256 . Example take an array c[256] , where c[i] gives the number of times i_th ASCII value is repeated . Then after you have obtained c[256] . Check for maximum 5 nos. in this array (which can be done in O(n) time and space). --

Re: [algogeeks] Re: double and int

2011-01-07 Thread Avi Dullu
I referred to the accuracy of result *acceptable to one*, if there are cases that 0.2 and 0.29 may occur, and u still want to go with a 1.0e-5 value as a zero equality check, its your code, screw it up. If one knows that such corner cases might come and he decides to discard them, fine,

Re: [algogeeks] Re: Adobe - Coding

2011-01-07 Thread Avi Dullu
@Decipher As far as I understand the problem it says returns the 5 most common occuring strings in a list, and the example u give is of a character array, when u go to a list of strings with len_of_each_string 1, u wil have to *hash* them, which is when u will run into problems with count sort.

Re: [algogeeks] Re: Adobe - Coding

2011-01-07 Thread Anand
From the questions example it seems they are looking for five most common character seen in the list. Please clarify on this. On Fri, Jan 7, 2011 at 2:02 PM, Avi Dullu avi.du...@gmail.com wrote: @Decipher As far as I understand the problem it says returns the 5 most common occuring strings

Re: [algogeeks] Re: Adobe Interview

2011-01-07 Thread Anand
This is absolutely longest increasing sub-sequence problem. Since rotation is not possible. For the given L and B values calculate the base area L * B for all the given values and sort it. From this sorted array calculate the longest increasing sub-sequence of H. The Out put sequence gives the

[algogeeks] Re: Adobe - Coding

2011-01-07 Thread Gene
Here's a different language from the usual to enjoy! This algorithm is O(n) where n is the length of the input. with Ada.Text_IO, Ada.Strings.Unbounded.Text_IO, Ada.Strings.Unbounded; use Ada.Text_IO, Ada.Strings.Unbounded.Text_IO, Ada.Strings.Unbounded; procedure Top5 is type Pair_Type

[algogeeks] Problem from ACM ICPC 2010

2011-01-07 Thread rgap
Hi, I need some help solving this problem from ICPC regionals, 2010, South America. http://acmicpc-live-archive.uva.es/nuevoportal/region.php?r=sayear=2010 Problem K - Kid's Wishes Each kid may wish to sit down next to at most two other kids, because each kid has just two neighbors in the circle.

Re: [algogeeks] Re: Adobe Interview

2011-01-07 Thread nishaanth
@anand...A small correction, in that longest increasing subsequence algorithm we also should make sure that the first two dimensions are also proper. Because sorting two dimensions based on area doesnt mean they fit. On Sat, Jan 8, 2011 at 4:40 AM, Anand anandut2...@gmail.com wrote: This is

Re: [algogeeks] Re: Amazon Intrerview

2011-01-07 Thread nishaanth
How about this solution, Do a DFS on the graph with x as the start node. If you get z , just see if y is in the stack, if its there then it is in the path,else it is not. correct me if i am wrong. On Fri, Jan 7, 2011 at 7:51 PM, juver++ avpostni...@gmail.com wrote: Heh, problem clearly stated

[algogeeks] Binary tree Mirror using iterative method

2011-01-07 Thread Rajesh
How to check whether the left subtree is an exact mirror of the right subtree using iterative methods. -- 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

Re: [algogeeks] Re: Adobe Interview

2011-01-07 Thread Anand
@nishaath you are correct. On Fri, Jan 7, 2011 at 9:03 PM, nishaanth nishaant...@gmail.com wrote: @anand...A small correction, in that longest increasing subsequence algorithm we also should make sure that the first two dimensions are also proper. Because sorting two dimensions based on area