Re: [algogeeks] Spoj_problem:INUMBER
BFS Regards Vaibhav On , Anshul AGARWAL anshul.agarwa...@gmail.com wrote: hi friends,im not able to find any logic to solve this problem. Can any one suggest me good algorithm of spoj_problem: (INUMBER). thanx in advance -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] JAVA: Print all paths from root to leaf
Although there is no pointer concept in java, but still underlying containers in java get passed through functions via there base address. What you want is to send a copy of your list again recursively. --- public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list.clone()); paths(node.right, list.clone()); } } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } --- Regards Vaibhav Mittal NSIT, Dwarka On , Mihir Kulkarni mihirk...@gmail.com wrote: Hello,This method below is not giving correct paths. Can someone please tell me the mistake. public static void paths(Node node, LinkedList list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); paths(node.right, list); } } public static void print(LinkedList list) { System.out.println(Contents of list: + list); } eg: 7 / 2 / \ 1 5 It prints: 7 2 1 7 2 1 5 cheers,Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: Re: [algogeeks] Re: Modular arithmetic + Combinatorics
correction: if P is prime VM NSIT, Dwarka On , vaibhavmitta...@gmail.com wrote: Use Lucas Theorem is P is prime. VM NSIT, Dwarka On , Dipit Grover dipitgro...@gmail.com wrote: Thats really cool! Thanks Dave :) -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Special String
Hint: It is a dp of the form f(n+3) = a*f(n+2) + b*f(n+1) + c*f(n) Figure a, b, c urself.. VM NSIT, Dwarka 3rd year, COE On , Amol Sharma amolsharm...@gmail.com wrote: Plz help me in solving a simple problem on spoj http://www.spoj.pl/problems/MAIN113/ i am not able to conclude a general formula for any 'n'i derived one but found it wrong...plz some one guide !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: [algogeeks] SPOJ 9199. Circular Track
divide absolute speeds by their GCD..and then the answer is their relative speed.. VM NSIT, Dwarka 3rd year, COE On , Prakash D cegprak...@gmail.com wrote: any1?? On Sun, Aug 7, 2011 at 7:16 PM, Prakash D cegprak...@gmail.com wrote: yeah, i also need to know the approach for this kind of problems asked in many places On Sun, Aug 7, 2011 at 3:58 PM, arvind kumar arvindk...@gmail.com wrote: Hi Can any1 pls help me in solving this? Two persons are running on a circular track either in the same direction or in the opposite direction, indefinitely. The speed of both of them is given to you. Speed will be positive in clockwise direction, and negative in anticlockwise direction. Print the number of distinct points, at which they will meet on the circle. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: [algogeeks] Re: adobe
Mukul, in first approach instead of sending the string again and again u can use the formula (a*b)%m = ((a%m)*(b%m))%m this way u can do sumthin like dis int count = 0, a = 1; while(a != 0) { count++; a = ((a*10)%n + 1) %n; } n later output a string consisting of count one's.. Regards VM 3rd Year, Computer Engineering, Netaji Subhas Institute of Technology. On , Mukul Gupta mukul.gupta...@gmail.com wrote: Manee, Nice Question. I have thought of two algorithms. I wanted to know how one judges them. Both have similar time complexity but the 2nd one is slightly complex and much more logical. 1. Keeping on adding 1 as a string of 1's and apply it to this modulo function to check when it becomes 0. long long modulo(char b[],long long a) {long long d=0,len,i,j,k; len=strlen(b); for (k=0;k {d*=10; d+=b[k]-48; d=d%a; } return d; } 2. Any number ending in 3 will have the last digit as 1 if it is multiplied by 7. Consider a case 13 ...let the required answer have 11.111. as its representation.13 x 7 = 91. So subtracting the 3 digit of of 111.. by 91...we get 111...11020Now we know that the ones digit of the required number is 7... Similarly, if the last digit of a ten's digit has to be '2'...The number has to be multiplied by 4.So we subtract 13 x 4 = 52 from. 1.02 to get 11...050...So we get the ten's digit as 4 Similarly, now for a number to end in 5...it has to be multiplied by 5we subtract...65 from 111...105to get 111..1040... Hundred's digit is 5 Similarly, now for a number to end in 4...it has to be multiplied by 8 ... we subtract 104 from 111...104to get 111...000. and thus we end the process as we have got the remainder as 0. Thus, our required answer is 13 x 8547 = 11 Now I want to know...that both the methods have similar complexity ie. O(k) where k is the number of 1's. However, 2nd is much more logical and complex. What does the company look for? Suggest some better methods or make ammends. Regards, Mukul Gupta 3rd Year, Computer Engineering, Netaji Subhas Institute of Technology. On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.com wrote: yes ur wrong..1 is nt divisible by 23 On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote: This looks quite simple. Every number ending in 3 follows a pattern.eg- 3 - 111 13 - 11 23 - 1 etc we can find the reauired no. by : suppose input no. is 33 In every case leave the no at 1's place(least significant) ie 3, In 33 you will be left with 3(after removal of 3 at first place). Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1) = 12 ie ). for 103 it is 3*(10+1) = 33 1's. Correct if I am wrong. On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote: ADOBE asks the very basic C/C++ questions one of their toughest however was : every number ending in 3 has a multiple of the form 111...111 eg 3 has 111 13 has 11 so on.. find the algo for finding the number for an input number ending in 3. On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote: hey, guys adobe is visiting our campus. So those who know questions that adobe asked in written or interview, please post here as it will be of great help (as adobe has visited some colleges already). Thank you in advance. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] aptitude
45 km/hr VM NSIT, COE, 3rd year On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: A car is traveling at a uniform speed.The driver sees a milestone showing a 2-digit number. After traveling for an hour the driver sees another milestone with the same digits in reverse order.After another hour the driver sees another milestone containing the same two digits. What is the average speed of the driver? -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: [algogeeks] aptitude
first milestone 16 second milestone 61 third milestone 106 its an observation..ntn like nethn..onli thing i tht ws dat as speed is uniform so distance traveled per hr is constant..so two milestones with reverse numbers wil hv difference as 9x-9y ie multiple of 9..also third milestone wil be very near to 100 to so 1 is fixed as a digit..odrs can be found out by hit and trial.. VM NSIT, COE, 3rd year On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: vaibhav can u please explain.i know the answer already..im just not able to solve the equations fully On Wed, Aug 3, 2011 at 7:09 PM, Arun Vishwanathan aaron.nar...@gmail.com wrote: in general, if u guys get any answer, please post a short explanation even if it the solution is very obvious to u...not everyone gets it when looking at the answer... On Wed, Aug 3, 2011 at 3:34 PM, vaibhavmitta...@gmail.com wrote: 45 km/hr VM NSIT, COE, 3rd year On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: A car is traveling at a uniform speed.The driver sees a milestone showing a 2-digit number. After traveling for an hour the driver sees another milestone with the same digits in reverse order.After another hour the driver sees another milestone containing the same two digits. What is the average speed of the driver? -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: [algogeeks] Re: MS
With the binary search we can decide for a value of size of square with reasonable error.. nw to check hw much % fill does that value of size gives..we can implement a dp..or a recursive substitute.. say size of rectangle is 'a' x 'b' and size of square chosen is 'x'.. we hv to fill a grid with squares of size 'x'..so greedily fill the squares across the length of rectangle(subject to N).. so recursive function wud luk sumthin like dis F(A,B,a,b,x,N) = gives the % fill = % fill + F(A,Bx,a,b,x,N-(squares filled across length)) where A x B is size of rectangle to fill, axb is maximum size of rectangle, x is size of square we are considering, N is remaining squares we can fill.. base cases wud be wen we cannot fill squares subjected to N = 0 or if A and B dont permit us to.. I hope dis helps mam. Regards VM NSIT, COE, 3rd yr On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: @vaibhav:can u please elaborate? On Tue, Aug 2, 2011 at 6:31 PM, Vaibhav Mittal vaibhavmitta...@gmail.com wrote: dynamic programming with binary search should do it.. Regards VM NSIT, COE, 3rd yr On Tue, Aug 2, 2011 at 6:19 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @sunny:yes all the squares should be of same size On Tue, Aug 2, 2011 at 5:03 PM, Poised~ dip10c...@gmail.com wrote: @ narain-i didn't see that coming. thanks for the heads up. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/oSuB8bJuqDcJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: Re: [algogeeks] Re: MS
I guess in the above solution greedy wont wrk..i just assumed it wud..dint prove it.. nevertheless..we can replace dis with.. F(A,B,a,b,x,N) = % fill + max( F(A,Bx,a,b,x,N-(squares filled across length)), F(Ax,B,a,b,x,N-(squares filled across breadth)) ) Regards VM NSIT, COE, 3rd yr On , vaibhavmitta...@gmail.com wrote: With the binary search we can decide for a value of size of square with reasonable error.. nw to check hw much % fill does that value of size gives..we can implement a dp..or a recursive substitute.. say size of rectangle is 'a' x 'b' and size of square chosen is 'x'.. we hv to fill a grid with squares of size 'x'..so greedily fill the squares across the length of rectangle(subject to N).. so recursive function wud luk sumthin like dis F(A,B,a,b,x,N) = gives the % fill = % fill + F(A,Bx,a,b,x,N-(squares filled across length)) where A x B is size of rectangle to fill, axb is maximum size of rectangle, x is size of square we are considering, N is remaining squares we can fill.. base cases wud be wen we cannot fill squares subjected to N = 0 or if A and B dont permit us to.. I hope dis helps mam. Regards VM NSIT, COE, 3rd yr On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: @vaibhav:can u please elaborate? On Tue, Aug 2, 2011 at 6:31 PM, Vaibhav Mittal vaibhavmitta...@gmail.com wrote: dynamic programming with binary search should do it.. Regards VM NSIT, COE, 3rd yr On Tue, Aug 2, 2011 at 6:19 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @sunny:yes all the squares should be of same size On Tue, Aug 2, 2011 at 5:03 PM, Poised~ dip10c...@gmail.com wrote: @ narain-i didn't see that coming. thanks for the heads up. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/oSuB8bJuqDcJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: Re: Re: [algogeeks] Re: MS
A and B are length and breath of current rectangle to fill.. in above example in the ques if i fill 1x1 squares along length of 3x5 rectangle..im left with a rectangle of 3x4(A x B) which i have to fill again.. Regards VM NSIT, COE, 3rd yr On , Tushar Bindal tushicom...@gmail.com wrote: i could not get what A and B stand for. pls elaborate a bit more on that On Tue, Aug 2, 2011 at 7:03 PM, vaibhavmitta...@gmail.com wrote: I guess in the above solution greedy wont wrk..i just assumed it wud..dint prove it.. nevertheless..we can replace dis with.. F(A,B,a,b,x,N) = % fill + max( F(A,Bx,a,b,x,N-(squares filled across length)), F(Ax,B,a,b,x,N-(squares filled across breadth)) ) Regards VM NSIT, COE, 3rd yr On , vaibhavmitta...@gmail.com wrote: With the binary search we can decide for a value of size of square with reasonable error.. nw to check hw much % fill does that value of size gives..we can implement a dp..or a recursive substitute.. say size of rectangle is 'a' x 'b' and size of square chosen is 'x'.. we hv to fill a grid with squares of size 'x'..so greedily fill the squares across the length of rectangle(subject to N).. so recursive function wud luk sumthin like dis F(A,B,a,b,x,N) = gives the % fill = % fill + F(A,Bx,a,b,x,N-(squares filled across length)) where A x B is size of rectangle to fill, axb is maximum size of rectangle, x is size of square we are considering, N is remaining squares we can fill.. base cases wud be wen we cannot fill squares subjected to N = 0 or if A and B dont permit us to.. I hope dis helps mam. Regards VM NSIT, COE, 3rd yr On , Kamakshii Aggarwal kamakshi...@gmail.com wrote: @vaibhav:can u please elaborate? On Tue, Aug 2, 2011 at 6:31 PM, Vaibhav Mittal vaibhavmitta...@gmail.com wrote: dynamic programming with binary search should do it.. Regards VM NSIT, COE, 3rd yr On Tue, Aug 2, 2011 at 6:19 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @sunny:yes all the squares should be of same size On Tue, Aug 2, 2011 at 5:03 PM, Poised~ dip10c...@gmail.com wrote: @ narain-i didn't see that coming. thanks for the heads up. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/oSuB8bJuqDcJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups
Re: [algogeeks] Re: Largest substring with unique characters
String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Fwd: [algogeeks] Re: Largest substring with unique characters
Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to
Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at
Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at
Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at
Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
Thanx for pointitn out the case :) Hope dis wil wrk. https://ideone.com/0LNkW On , Pankaj jatka.oppimi...@gmail.com wrote: aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,