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

2012-08-16 Thread Wei.QI
@yq, didn't I ask you this question before? On Fri, Aug 10, 2012 at 4:48 PM, yq Zhang wrote: > @shiv, your code is correct go compute the base 26 number. However, this > question is not base 26 number obviously. > > > > On Wed, Aug 8, 2012 at 4:46 AM, shiv narayan > wrote: >> >> this is similar

Re: [algogeeks] one more from amazon

2011-02-06 Thread Wei.QI
public static ArrayList> Partition(int val, int start, int size) { ArrayList> r = new ArrayList>(); if (start * size > val) { return null; } if(size == 1) { r.add(new ArrayList()); r.get(0).add(val); return r; } for (int i = start; i <= val/size; i++) { ArrayList>

Re: [algogeeks] Re: google questions

2011-02-02 Thread Wei.QI
This is a standard map reduce problem. 1. reduce the file by word: sending words into machines based on it's val. 2. count words, return top 10 words in each machine. 3. aggregate results together to get top 10. -weiq On Wed, Feb 2, 2011 at 8:46 AM, bittu wrote: > @sankalp ...You seems to be r

Re: [algogeeks] Excel Sheet Question Asked

2011-02-01 Thread Wei.QI
@albert, You need to becareful when doing the divide, because there is no ZERO. (Z -> AA not Z->A0). here is the code: public static String ExcelMapIntToStr(int n) { StringBuilder sb = new StringBuilder(); while(n>0) { sb.append((char)(('A' - 1) + (n-1)%26 + 1)); n = (n-1)/26; } return sb

Re: [algogeeks] Re: Amazon Again

2011-01-30 Thread Wei.QI
-1; //otherwise continue to go, until back to start for(int i=0; i 0){ leftGas = left; }else { return -1; } } return start; } On Sun, Jan 30, 2011 at 9:55 AM, Wei.QI wrote: > For any gas pump, when your car arrives, it contains 0 or more gas. > So, for each gas pump, the worst case is star

Re: [algogeeks] Re: Amazon Again

2011-01-30 Thread Wei.QI
. This could be solved in liner time. finding a possible start pump use O(n) and prove it use another O(n). -weiq On Sat, Jan 29, 2011 at 9:47 PM, nishaanth wrote: > @Wei.Qi Can you clarify when your algorithm terminates and also what > is the running time of the algorithm ? > > >

Re: [algogeeks] Re: Amazon Again

2011-01-29 Thread Wei.QI
Starting with any pump A, try to finish the circle, if at pump B that can not reach pump B+1, it means all pumps from A to B can not finish the circle (it will go broke at pump B), then just start with B+1. After go through all the pumps start from some pump, we got an answer. if we go back to pump

Re: [algogeeks] Re: google written

2011-01-15 Thread Wei.QI
current = currentnext; // +1; should not move forward here, > } > } On Sat, Jan 15, 2011 at 1:55 PM, Jammy wrote: > @Wei Please test you code on "cdbbcbbca". I believe it outputs 2 > instead of 8. > > On Jan 14, 4:09 am, "Wei.Q

Re: [algogeeks] google written

2011-01-14 Thread Wei.QI
@juver++, can you give me a test case that will time out? On Fri, Jan 14, 2011 at 6:44 AM, juver++ wrote: > @qw > I think you solution will timed out?! > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send ema

Re: [algogeeks] google written

2011-01-14 Thread Wei.QI
FindStartIndex(char[] a) { int start = 0; int current = 1; while(current < a.Length) { if(a[current] < a[start]) { start = current; ++current; }else if(a[current] > a[start]) { ++current; }else //a[current]

Re: [algogeeks] probability

2011-01-14 Thread Wei.QI
x is even number probability 0.9x + x = 1 x = 1/1.9 P(2) = P(4) = P(6) = (1 / 1.9) / 3 P(4|5|6) = (P(4) + P(6)) / 0.75 = 2 / 1.9 / 3 / 0.75 = 0.4678362573099415 -weiq On Thu, Jan 13, 2011 at 11:29 PM, snehal jain wrote: > An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The > p