Re: [algogeeks] Array problem

2012-03-13 Thread sachin sabbarwal
@gaurav popli: how about this one?? findsummat(int arr[],int n) { int *sum ; sum =(int*)malloc(sizeof(int)*n); for(int i=0;iwrote: > @piyush : sorry dude , didnt get your algo . actually you are using > different array and i get confused which array to be considered when. > > > > On Mon

[algogeeks] Re: Novell - Interview (Round-3 Coding)

2012-03-13 Thread Gene
Let's try { reverse( $ a b a a b a a a b ... a^n b ) | n = 0,1,2,... } . Note that m = n(n+1)/2 + n = O(n^2) Think about adding suffixes to the tree from shortest to longest. So suppose you are now adding something of the form reverse( $ X a^L Y ) where L is the length of the longest run of

[algogeeks] Re: Novell - Interview (Round-3 Coding)

2012-03-13 Thread Gene
{ reverse( $ a b a a b b a a a b b b ... a^n b^n ) | n = 0,1,2,... } On Mar 13, 12:47 am, reynald reni wrote: > Construct an infinite family of strings over a fixed alphabet, where > the total length of the edge-labels on their suffix tree grows faster > than O(m), where 'm' is the length of the

[algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Gene
Sorry, a small test showed a loop quitting one iteration too soon. Here is the fix. import java.util.Random; public class ListCopy { class Node { int val; Node next, other; Node() { } Node(int val, Node next, Node other) { this.val = val;

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread Sourabh Singh
@atul read it .. it's good but more or less like the histogram algo.. i wanted a DP. approach.. here is some of wat i heard from a senior in colg.. 1. at every index we can keep 4 variable ht: height of max rectangle possible at index above current wt width " " " "

[algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Gene
Copying a full graph requires a BFS or DFS. But here we have a big advantage. We know the nodes are linked in a single chain. So we don't need to search to find all nodes. We can just use .next pointers. No matter how we do things, we will need Map(A) that returns the copy of node A if it alre

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread atul anand
@ Sourabh: check solution i have posted in below link http://groups.google.com/group/algogeeks/browse_thread/thread/91a17f7c78c2319e/991d1c2625a62ff0?hl=en&lnk=gst&q=rectangle+of+max+sum+MS+Q#991d1c2625a62ff0 On Tue, Mar 13, 2012 at 10:26 PM, Sourabh Singh wrote: > @ ALL > > finding square mat

[algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Gene
This problem is close to copying a graph. For that as you said, just do DFS or BFS and maintain a map from original nodes to copies. Use the copy to set pointers whenever it exists. When it doesn't exist, make a new node and add it to the map. You can implement the map in various ways. A hash t

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread Sourabh Singh
@ ALL finding square matrix is quite a standard question and nw an easy one as everyone knows the reccussence atul has given. but i wanted to find max rectangle.. i know there is a DP for it. in O(n^2). for nxn matrix..don't know the whole approach .but here is what i remember.. 1. aproach i

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread rahul sharma
wats d logic behind this??? On Tue, Mar 13, 2012 at 11:59 AM, atul anand wrote: > here is the recurrence for solving this > > R[i, j] = (M[i,j] == 0 ? 0 : 1 + min( R[i-1, j], R[i-1, j-1], R[i,,j-1] ) > ); > > On Tue, Mar 13, 2012 at 11:48 AM, rahul sharma wrote: > >> >> April 4, 2010 >> >> Given

Re: [algogeeks] Hi

2012-03-13 Thread rahul sharma
interview-str...@googlegroups.com, On Tue, Mar 13, 2012 at 8:34 AM, Supraja Jayakumar wrote: > Hi > > Yes I will do that. I posted it to interview-str...@googlegroups.com. I > do not find this group's id right. Pls tell me the id to which I have to > subscribe. > > Thanks > > > On Mon, Mar 12, 2

Re: [algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Dheeraj Sharma
http://www.geeksforgeeks.org/archives/1155 On Tue, Mar 13, 2012 at 11:31 AM, Umer Farooq wrote: > Yes that is exactly what they wanted. I proposed BFS for this solution. > Anyway, there was another problem that I was able to solve; but the > interviewer brought up a much more efficient approach.

Re: [algogeeks] Novell - Round-2 Question (Common Substring)

2012-03-13 Thread reynald reni
Could anyone please tell me if Suffix Trees would be appropriate here to use? or kindly suggest me a better data structure. On 3/13/12, reynald reni wrote: > Chunyuan, can this complexity be still reduced with any other data > structure? > > On 3/13/12, Chunyuan Ge wrote: >> it's a classic probl

Re: [algogeeks] Novell - Round-2 Question (Common Substring)

2012-03-13 Thread reynald reni
Chunyuan, can this complexity be still reduced with any other data structure? On 3/13/12, Chunyuan Ge wrote: > it's a classic problem like Time = O(n*n), space = O(n) > > On Tue, Mar 13, 2012 at 12:55 PM, InThirstOfWisdom.rr < > reni.reyn...@gmail.com> wrote: > >> Algorithm to find the longest co

Re: [algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Umer Farooq
Yes that is exactly what they wanted. I proposed BFS for this solution. Anyway, there was another problem that I was able to solve; but the interviewer brought up a much more efficient approach. The problem was: - Given a linked a linked list with one pointer pointing to next, another poin

Re: [algogeeks] Re: Microsoft Interview Question

2012-03-13 Thread Umer Farooq
Yes that is exactly what they wanted. I proposed BFS for this solution. Anyway, there was another problem that I was able to solve; but the interviewer brought up a much more efficient approach. The problem was: Given a linked l On Mon, Mar 12, 2012 at 11:31 PM, Gene wrote: > Since there is no