Re: [algogeeks] Re: AMAZON: given col id, print col name in excel

2012-08-19 Thread coolfrog$
@shiva: Nice thinking, man... :) @Yq Zhang: this similar to base 26 apporch, i have tested below code for boundary cases , 0, 26(z), 27(aa), 26*26(yz), 26*27(zz) public String getColName(int id) { char ch[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',

Re: [algogeeks]

2012-08-19 Thread Ashish Goel
what is the rational to do 5*rand5() why not 4*rand5 or 6 *rand5?? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jun 22, 2012 at 10:13 AM, Anant Sharma black.b...@gmail.com wrote: The reason why finding a solution to this question is

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread Carl Barton
Just calculating the suffix array solves the problem if you do it with the LCP array as well. You don't need to 'use' the suffix array so to speak. On 19 August 2012 21:45, pankajsingh psingh...@gmail.com wrote: Is there any O(n) solution this question...I Cleared all the testcases but my

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread Carl Barton
Or a suffix tree would work. Pre process it to answer Lowest common ancestor queries. On 19 August 2012 21:51, Carl Barton odysseus.ulys...@gmail.com wrote: Just calculating the suffix array solves the problem if you do it with the LCP array as well. You don't need to 'use' the suffix array so

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread pankajsingh
@Carl- I didnt got ur point completely abt Lcp array..can you demonstrate on the below example... Example for ababaa answer shud be -11 suffix array wud be:- a aa abaa ababaa baa and Lcp array would be then 0 1 1 3 0 ..correct if wrong..whats next... -- You received this message because you

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread Carl Barton
Oh, I actually read the question totally wrong. I think this idea is linear, but it's late so I'm not sure. 1. Calculate suffix array and lcp array for the text. 2. Calculate the longest common prefix between your text and the first entry in your suffix array and initialise a variable called

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread atul anand
concatenate 2 strings adding wild character in between i.e A=aaa B=aaab A+B =aaa$aaab; wild character is $; now create longest prefix table(partial match table) as we do in KMP algo. now search for max value after $ index...in LPS table. I guess it would work On Sun, Aug 19, 2012 at 8:23

Re: [algogeeks] O(n) solution is there or not!!

2012-08-19 Thread pankajsingh
@carl- got ur point..but complexity is more..suffix array takes o(n^2lgn)..considering string comparisons. complexity to build...i already have o(n^2)..want o(n).. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Re: Printing random word from file

2012-08-19 Thread Navin Kumar
@Dave sir, I didn't get your logic. Can you please elaborate it? On Sun, Aug 19, 2012 at 4:08 AM, Dave dave_and_da...@juno.com wrote: @Navin: Here is the algorithm: Save the first word. For i = 2, 3, ..., n = number of words in the file replace the saved word with the i-th word with