[algogeeks] Re: linked lists

2010-10-21 Thread ligerdave
@Asquare you were right. what about this? public static char[] concat(char[] str1, char[] str2) { boolean repeat = false;// indicates whether two neighbor chars repeat in // str1 array int pointer = -1; // pointer for str2 array

[algogeeks] Re: linked lists

2010-10-21 Thread ligerdave
@asquare basically i just added a flag to enable the window slide. good catch btw! On Oct 20, 7:55 am, Asquare anshika.sp...@gmail.com wrote: @ligerdave - your algo will fail in the case the two arrays are: hellostl eeelexander ans : hellostlexander but according to ur method the

[algogeeks] Re: linked lists

2010-10-20 Thread Sudheendra
Is there any additional condition saying if last 'n' characters of first list should match with first 'n' characters of 2nd list ? On Oct 7, 12:52 pm, snehal jain learner@gmail.com wrote: There are two linked list, both containing a character in each node. If one linked list contain

[algogeeks] Re: linked lists

2010-10-20 Thread Asquare
@ligerdave - your algo will fail in the case the two arrays are: hellostl eeelexander ans : hellostlexander but according to ur method the answer would end up being hellostleeelexander -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: linked lists

2010-10-16 Thread nishaanth
@Snehal...wat ligerdave says is have ptr1 for list1 and ptr2 for list2. if(ptr1-data==ptr2-data)increment both ptr1 and ptr2 else reset ptr2 to the head of list2 , increment ptr1 ptr2 position gives from where we need to concatenate. On Sat, Oct 9, 2010 at 12:21 AM, ashita dadlani

Re: [algogeeks] Re: linked lists

2010-10-08 Thread snehal jain
@tech the ouput will be abhgrtsghgrthswert as no suffix of 1st matches with prefix of 2nd On 10/7/10, ligerdave david.c...@gmail.com wrote: use pointer. shift to left if one more leading char has been found. any unmatched char resets the pointer to first char once you went through the

Re: [algogeeks] Re: linked lists

2010-10-08 Thread snehal jain
@neeraj ur worst case complexity will be O(mn) On 10/8/10, snehal jain learner@gmail.com wrote: @tech the ouput will be abhgrtsghgrthswert as no suffix of 1st matches with prefix of 2nd On 10/7/10, ligerdave david.c...@gmail.com wrote: use pointer. shift to left if one more leading

Re: [algogeeks] Re: linked lists

2010-10-08 Thread snehal jain
@ligerdave m nt getting ur algo..can u explain with an example On 10/8/10, snehal jain learner@gmail.com wrote: @neeraj ur worst case complexity will be O(mn) On 10/8/10, snehal jain learner@gmail.com wrote: @tech the ouput will be abhgrtsghgrthswert as no suffix of 1st matches

[algogeeks] Re: linked lists

2010-10-07 Thread ligerdave
use pointer. shift to left if one more leading char has been found. any unmatched char resets the pointer to first char once you went through the entire list(first one), the pointer on the second list tells you where to concatenate that gives you O(n) where n is the length of first list On Oct