Re: [algogeeks] Google Interview Question: In how many intervals does a number exists

2013-06-09 Thread Avi Dullu
Read up on Interval trees . Programmers should realize their critical importance and responsibility in a world gone digital. They are in many ways similar to the priests and monks of Europe's Dark Ages; they are the only ones with the training and insigh

Re: [algogeeks] Google Interview Question: In how many intervals does a number exists

2013-06-09 Thread Prateek Jain
2->2 as 2 lies in [2,3] and [1,4] ? On Sun, Jun 9, 2013 at 12:50 PM, Monish Gupta wrote: > There are n Intervals. Given a set of m numbers, tell in how many > intervals does each number exists. > Example: 4 Intervals: [2,3] [3,4] [1,4] [3,10]. Numbers {2,4,11} > For 2 -> 1 as 2 lies only in 1 in

[algogeeks] Google Interview Question: In how many intervals does a number exists

2013-06-09 Thread Monish Gupta
There are n Intervals. Given a set of m numbers, tell in how many intervals does each number exists. Example: 4 Intervals: [2,3] [3,4] [1,4] [3,10]. Numbers {2,4,11} For 2 -> 1 as 2 lies only in 1 interval [2,3] For 4 -> 3 as 4 lies in 3 intervals For 11 -> 0 as 11 lies in none of the given 4 inte

[algogeeks] Google Interview question - Python

2012-11-01 Thread Raghavan
I got this question set in google interview, do any one have some knowledge how to do this, One way of imagining a lazy stream implementation in python is any class that implements the method: popNext() which returns the next element of the stream, if any, otherwise None. 1. Write the following c

[algogeeks] Google interview question

2011-11-26 Thread Nitin Garg
Hi Guys I saw this question http://stackoverflow.com/questions/8189334/google-combinatorial-optimization-interview-problm But couldn't get the solution which has been accepted, nor could work out one on my own. Please help! -- Nitin Garg "Personality can open doors, but only Character can keep t

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Siddhartha Banerjee
lol!!! -- 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 thi

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Anup Ghatage
FFS. here you go: http://lmgtfy.com/?q=google+careers On Sat, Oct 1, 2011 at 2:09 PM, Deepak Garg wrote: > hey can pls share the link. > > thnks > > > On Sat, Oct 1, 2011 at 2:04 PM, Rathish Kannan wrote: > >> apply through google careers site... >> >> -- RK :) >> >> >> >> On Sat, Oct 1, 20

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Deepak Garg
hey can pls share the link. thnks On Sat, Oct 1, 2011 at 2:04 PM, Rathish Kannan wrote: > apply through google careers site... > > -- RK :) > > > > On Sat, Oct 1, 2011 at 2:02 PM, Deepak Garg wrote: > >> hey,,,what is the process of attending google offcampus process. >> >> kindly let us kn

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Rathish Kannan
apply through google careers site... -- RK :) On Sat, Oct 1, 2011 at 2:02 PM, Deepak Garg wrote: > hey,,,what is the process of attending google offcampus process. > > kindly let us know.. > > > On Sat, Oct 1, 2011 at 1:52 PM, Rathish Kannan wrote: > >> off campus. >> >> -- RK :) >> >> >> >>

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Deepak Garg
hey,,,what is the process of attending google offcampus process. kindly let us know.. On Sat, Oct 1, 2011 at 1:52 PM, Rathish Kannan wrote: > off campus. > > -- RK :) > > > > On Sat, Oct 1, 2011 at 11:59 AM, arvind kumar wrote: > >> Hi >> Are u attending off-campus or on-campus interview? >> >>

Re: [algogeeks] Google Interview Question

2011-10-01 Thread Rathish Kannan
off campus. -- RK :) On Sat, Oct 1, 2011 at 11:59 AM, arvind kumar wrote: > Hi > Are u attending off-campus or on-campus interview? > > On 10/1/11, R@TH!$H wrote: > > Hi, > > > > I am attending Google interview on Monday. Please help me with sample > > questions. > > > > Thanks & Regards, >

Re: [algogeeks] Google Interview Question

2011-09-30 Thread arvind kumar
Hi Are u attending off-campus or on-campus interview? On 10/1/11, R@TH!$H wrote: > Hi, > > I am attending Google interview on Monday. Please help me with sample > questions. > > Thanks & Regards, > Rathish Kannan > > -- > You received this message because you are subscribed to the Google Groups >

[algogeeks] Google Interview Question

2011-09-30 Thread R@TH!$H
Hi, I am attending Google interview on Monday. Please help me with sample questions. Thanks & Regards, Rathish Kannan -- 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 unsubs

Re: [algogeeks] Google Interview Question

2011-08-01 Thread Manmeet Singh
Your code does not works proper;y for all cases On Mon, Aug 1, 2011 at 10:42 PM, Rohit jalan wrote: > Here is the recursive algo: > > Rearrange(A,p,q) > 1. if p is not equal to q do the following > 2. r ← (p+q)/2 > 3. Exchange A[(p+r)/2..r] ←→ A[(p+q)/2 +1 ..(r+q)/2]. > 4. Rearrange(A,p,r) > 5.

Re: [algogeeks] Google Interview Question

2011-08-01 Thread Rohit jalan
Here is the recursive algo: Rearrange(A,p,q) 1. if p is not equal to q do the following 2. r ← (p+q)/2 3. Exchange A[(p+r)/2..r] ←→ A[(p+q)/2 +1 ..(r+q)/2]. 4. Rearrange(A,p,r) 5. Rearrange(A,r+1,q) 6. return On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta wrote: > A is an array of size 2n such

Re: [algogeeks] Google Interview Question

2011-08-01 Thread kumar raja
It is a bit tricky without using external memory .It is like insertion sort. correct me if i am wrong. for(i=n;i<2*n;i++) { x=a[i]; for(j=i-1;;j--) { if(j==0 || a[j-1]=='c') // 'c' indicates some character you can check its ascii value break; a[j+1]=a[j];

Re: [algogeeks] Google Interview Question

2011-08-01 Thread kumar raja
It is a bit tricky without using external memory correct me if i am wrong. for(i=n;i<2*n;i++) { On 1 August 2011 02:42, shady wrote: > when was this question asked in Google ? approximate date ? position ? > > > On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta wrote: > >> A is an array of size 2

Re: [algogeeks] Google Interview Question

2011-08-01 Thread shady
when was this question asked in Google ? approximate date ? position ? On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta wrote: > A is an array of size 2n such that first n elements are integers in any > order and last n elements are characters. > i.e. A={i1 i2 i3 in c1 c2 c3... cn} > then we ha

[algogeeks] Google Interview Question

2011-08-01 Thread Abhishek Gupta
A is an array of size 2n such that first n elements are integers in any order and last n elements are characters. i.e. A={i1 i2 i3 in c1 c2 c3... cn} then we have to rearrange the elements such that final array is A ={ i1 c1 i2 c2 .. in cn} Example : input : A ={ 5,1,4,d,r,a}; output : A=

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
thats the challenge man ! if u are declaring a static Array of 2GB and u might find the repeated element in second step then memory is waste ! Thats why hashing ! hashing has complexity of O(n) only ! Instead you can simply use a BBST but complexity is O(n lgn) On Fri, Jul 15, 2011 at 7:11 PM, Ana

Re: [algogeeks] Google interview question

2011-07-15 Thread Anand Shastri
File has 4,300,000,000 integers if you hash it will create a distinct hash for 4,300,000,000 integers. On Fri, Jul 15, 2011 at 7:09 PM, radha krishnan < radhakrishnance...@gmail.com> wrote: > if number is (1<<31) -1 u declare a 2GB array ? > > On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri > w

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
if number is (1<<31) -1 u declare a 2GB array ? On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri wrote: > file any way contains integers why do we need hash those integers? why not > use the same integers to index an array. > > On Fri, Jul 15, 2011 at 6:36 PM, radha krishnan > wrote: >> >> just h

Re: [algogeeks] Google interview question

2011-07-15 Thread Anand Shastri
file any way contains integers why do we need hash those integers? why not use the same integers to index an array. On Fri, Jul 15, 2011 at 6:36 PM, radha krishnan < radhakrishnance...@gmail.com> wrote: > just hash it > > On Fri, Jul 15, 2011 at 6:28 PM, Anand Shastri > wrote: > > Given a file c

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
just hash it On Fri, Jul 15, 2011 at 6:28 PM, Anand Shastri wrote: > Given a file containing 4,300,000,000  integers, how > can you find one that appears at least twice > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this

[algogeeks] Google interview question

2011-07-15 Thread Anand Shastri
Given a file containing 4,300,000,000 integers, how can you *find **one* that *appears* at *least **twice* -- 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 t

Re: [algogeeks] Google Interview Question

2011-06-05 Thread Wladimir Tavares
Greedy Algorithm: Sort descending elements using the following order: A & B are the concatenation of A and B. Following Set the order relation Between the numeric strings A wrote: > @piyush : > > hey buddy, check out carefully i think you missed something. > > my solution says it's 18 ->18111 >

Re: [algogeeks] Google Interview Question

2011-06-05 Thread Nikhil Jindal
@Bhavesh: Counter case for you: array = {68, 6867} u change this array to: {6866, 6867} then u sort them to get 6867, 6866 and then give the ans as: 686768. While the correct ans is: 686867 The problem in ur algo is in appending the first digit at the end of each number. For a correct algo, not j

Re: [algogeeks] Google Interview Question

2011-06-05 Thread Nikhil Jindal
@Naveen: Here's a counter case: 162, 16 The next digit(2) is not greater than the last equal digit(6), still 162 comes before 16. Here, as is done in ashu's algo, the next digit (2) should be compared with first digit(1) and not the last equal digit(6). Cheers Nikhil Jindal http://sites.google.c

Re: [algogeeks] Google Interview Question

2011-06-05 Thread Anurag Bhatia
I think what' required is that we compare digits - eg. 18 187 Since last digit of second num > First digit of first number - 18718 48 482 Since last digit of second num < First digit of first number - 48482 --Anurag On Mon, May 30, 2011 at 3:38 PM, Piyush Sinha wrote: > @Bhavesh... > > for

Re: [algogeeks] Google Interview Question

2011-06-05 Thread Nikhil Jindal
Anshu here has given a Perfect soln! Sunny's code is also correct but is a bit less efficient than anshu's. Cheers Nikhil Jindal http://sites.google.com/site/aboutnikhiljindal/ On Fri, May 27, 2011 at 9:11 PM, anshu mishra wrote: > @all go through this code > > #include > #include > > using name

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Bhavesh agrawal
@piyush : hey buddy, check out carefully i think you missed something. my solution says it's 18 ->18111 187->18711 and i think you will count it carefully... plz let me know in any case if my solution goes wrong anywhere . -- You received this message because y

Re: [algogeeks] Google Interview Question

2011-05-30 Thread snehi jain
ok ... got it thanks ... :) On Mon, May 30, 2011 at 5:25 PM, Maksym Melnychok wrote: > @halo check my previous messages > > we multiply every element by 10 and add 1 > > 90, 9 -> 901, 91 > 901, 91 -> 0.901, 0.91 > sort -> 0.91, 0.901 > revert -> 9, 90 > join -> 990 > > -- > You received this me

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Maksym Melnychok
@halo check my previous messages we multiply every element by 10 and add 1 90, 9 -> 901, 91 901, 91 -> 0.901, 0.91 sort -> 0.91, 0.901 revert -> 9, 90 join -> 990 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send e

Re: [algogeeks] Google Interview Question

2011-05-30 Thread snehi jain
@Maksym what if we have 90 and 9 they become .9 and .9 now what to do to get result as 990 and not 909. correct me if i am going somewhere wrong? On Mon, May 30, 2011 at 3:55 PM, Maksym Melnychok wrote: > @Sunny i explained how to deal with edgecases right after my post > > 1, 101 -> 11, 1011

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Maksym Melnychok
@Sunny i explained how to deal with edgecases right after my post 1, 101 -> 11, 1011 11, 1011 -> 0.11, 0.1011 sort -> 0.11, 0.1011 restore -> 1, 101 join -> 1101 i can't think of any fail examples anymore -- You received this message because you are subscribed to the Google Groups "Algorithm G

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Piyush Sinha
@Bhavesh... for the inputs 18,187.. apply your method.. 18 -- 188 187-- 187 18187 -> ur method 18718 -> actual On Mon, May 30, 2011 at 3:28 PM, Bhavesh agrawal wrote: > solution may be > > > array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all > exceptions ) > > then ,change this

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Bhavesh agrawal
solution may be array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all exceptions ) then ,change this array like 3 , 21222, 9, 93999, 17111, 17811, 1 , 10111 ( make each number of 5 digit with rest digits same as Ist digit ) then sort this array 9, 93999,3 2122

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Maksym Melnychok
possible fix for 100 10 edgecases would be to simply array.map{|x| x*10+1} and then get rid of that after sorting -- 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

Re: [algogeeks] Google Interview Question

2011-05-30 Thread sunny agrawal
@ Maksym Melnychok Fails i think some explanation say we have numbers 1 , 101 divide all by something to get 0.1, 0.101 simple sort will give you 0.101, 0.1 multiply all numbers to get original ones 101,1 join 1011 but correct answer should be 1101, isn't it ?? correct me if i m wrong ?? -- Su

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Maksym Melnychok
some explanation say we have numbers 2 3 5 78 divide all by something to get 0.2, 0.3, 0.5, 0.78 simple sort will give you 0.78, 0.5, 0.3, 0.2 multiply all numbers to get original ones 78 5 3 2 join 78532 -- You received this message because you are subscribed to the Google Groups "Algorithm Ge

Re: [algogeeks] Google Interview Question

2011-05-30 Thread snehi jain
i guess Sunny has already mentioned (concatenating the two numbers and comparing) this technique before, i liked and tried coding it ... it works perfectly without comparing the second digit incase the first is same. the algorithm can run in O(nlogn) taking the best sorting technique , though i h

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Sudhir mishra
give some explanation -- 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, vi

Re: [algogeeks] Google Interview Question

2011-05-30 Thread ankit sambyal
@Nave :: nice solution :) Phoda Sambyal On Mon, May 30, 2011 at 12:13 AM, Naveen Agrawal wrote: > @ shubham > > Your solution need some changes at step 2 > > step 1: >sort the given numbers in the decreasing order based on their first > digit(left most). > > step 2: >

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Naveen Agrawal
@ shubham Your solution need some changes at step 2 step 1: sort the given numbers in the decreasing order based on their first digit(left most). step 2: if two numbers come out to be equal in the above case & both of their next digit exist then sort on the basis of their next digit

Re: [algogeeks] Google Interview Question

2011-05-29 Thread KRQ
but ,when the arr is 78 3 to add 0 78 30 sort: 30 78 ans:378? 2011/5/27 Logic King > i agree with piyush...can't find the countercase...satisfied with the algo. > > > On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > >> how about adding zeroes at the end of integers to make to equal to the

Re: [algogeeks] Google Interview Question

2011-05-29 Thread Vishal Jain
Can this work... Lets say I have following numbers 8 9 7 4 2 121 23 21 24 27 35 79 2334 6785 Now repeat the last number to make all the number of equal length... 1211 2333 2111 2444 2777 3555 7999 2334 6785 Sort the following numbers in descending order. 7999 7

Re: [algogeeks] Google Interview Question

2011-05-29 Thread Ashish Goel
Radix/bucket sort.. won't that help? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, May 27, 2011 at 7:15 PM, wrote: > how about this case: > > 9, 100 -> 9100 > 100 9 > 9100 > > 2, 3, 9, 78 --> > 78 9 3 2 > 9 78 3 2 > > I guess solutio

Re: [algogeeks] Google Interview Question

2011-05-27 Thread sunny agrawal
will it work modifying the comparison function of the sort as follows generate two new numbers c and d from arguments a,b as c = ab; //concatenation d = ba; compare c and d if c >= d return true means a will come before b in final ordering else return false means b will come before in final order

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@srajan: ya , i made a mistake...the correct ans will of-course be 9978 On Fri, May 27, 2011 at 12:11 PM, srajan dongre wrote: > @ankit sambyal.i think d rite answer will be 9978 in dat case. > > > > > On Fri, May 27, 2011 at 11:50 PM, ankit sambyal wrote: > >> @shubam: won't work

Re: [algogeeks] Google Interview Question

2011-05-27 Thread srajan dongre
@ankit sambyal.i think d rite answer will be 9978 in dat case. On Fri, May 27, 2011 at 11:50 PM, ankit sambyal wrote: > @shubam: won't work >try following test case: 8,89,9 > > Ankit Sambyal > > > > On Fri, May 27, 2011 at 11:11 AM, shubham wrote: > >> check whether these steps wo

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@shubam: won't work try following test case: 8,89,9 Ankit Sambyal On Fri, May 27, 2011 at 11:11 AM, shubham wrote: > check whether these steps work: > > step 1: > sort the given numbers in the decreasing order based on their first > digit. > step 2: > if two numbers come o

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@shubham, 10 101 ?? On Fri, May 27, 2011 at 11:41 PM, shubham wrote: > check whether these steps work: > > step 1: > sort the given numbers in the decreasing order based on their first > digit. > step 2: > if two numbers come out to be equal in the above case & both of > their ne

Re: [algogeeks] Google Interview Question

2011-05-27 Thread shubham
check whether these steps work: step 1: sort the given numbers in the decreasing order based on their first digit. step 2: if two numbers come out to be equal in the above case & both of their next digit exist then sort on the basis of their next digit, otherwise the number

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@Piyush: try 97,8,9 acc. to ur algo, adding 0s: 97,80,90 then sorting : 97,90,80 so final ans acc. to ur algo: 9798 whereas the correct ans is : 9897 Ankit BITS Pilani On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > how about adding zeroes at the end of integers to make to equal to

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
Kadane's algorithm is considers subarray sum, we are considering concatenation here. On Fri, May 27, 2011 at 9:45 PM, Supraja Jayakumar wrote: > Hi > > Isnt this the Kadane's (largest subarray) problem ? > > Rgds > Supraja J > > On Fri, May 27, 2011 at 9:41 AM, anshu mishra > wrote: > >> @all g

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Supraja Jayakumar
Hi Isnt this the Kadane's (largest subarray) problem ? Rgds Supraja J On Fri, May 27, 2011 at 9:41 AM, anshu mishra wrote: > @all go through this code > > #include > #include > > using namespace std; > bool compare(int a, int b) > { > string u, v; > u = v = ""; > while (

Re: [algogeeks] Google Interview Question

2011-05-27 Thread anshu mishra
@all go through this code #include #include using namespace std; bool compare(int a, int b) { string u, v; u = v = ""; while (a) { u += (a % 10 + '0'); a/=10; } while (b) { v += (b % 10 + '0');

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@Aakash, yeah missed that, overriding default string comparator while sorting will do that. On Fri, May 27, 2011 at 8:11 PM, Arpit Mittal wrote: > @piyush : > > for 1, 100 > > you did > 100,100 > then sort > result 100,100 > > so u said ans is 1100 but it could also be 1001 as 100=100... > > co

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Arpit Mittal
@piyush : for 1, 100 you did 100,100 then sort result 100,100 so u said ans is 1100 but it could also be 1001 as 100=100... correct me if i am wrong? On Fri, May 27, 2011 at 7:39 AM, Aakash Johari wrote: > @vipul: try for 100 and 10 > > > 2011/5/27 • » νιρυℓ « • > >> @Piyush Sinha, >> what

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Aakash Johari
@vipul: try for 100 and 10 2011/5/27 • » νιρυℓ « • > @Piyush Sinha, > what about 9, 801 > > 2011/5/27 • » νιρυℓ « • > >> Take input as vector of string or array of string >> sort the vector >> print from end to beginning >> >> >> On Fri, May 27, 2011 at 7:51 PM, Logic King >> wrote: >> >>> i

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@Piyush Sinha, what about 9, 801 2011/5/27 • » νιρυℓ « • > Take input as vector of string or array of string > sort the vector > print from end to beginning > > > On Fri, May 27, 2011 at 7:51 PM, Logic King wrote: > >> i agree with piyush...can't find the countercase...satisfied with the >> alg

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
Take input as vector of string or array of string sort the vector print from end to beginning On Fri, May 27, 2011 at 7:51 PM, Logic King wrote: > i agree with piyush...can't find the countercase...satisfied with the algo. > > > On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > >> how about

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Logic King
i agree with piyush...can't find the countercase...satisfied with the algo. On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > how about adding zeroes at the end of integers to make to equal to the > integer with maximum number of digits and sort them... > > ex- > 101 10 > > adding zeroes.. >

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Piyush Sinha
how about adding zeroes at the end of integers to make to equal to the integer with maximum number of digits and sort them... ex- 101 10 adding zeroes.. 101 100 sort 100 101 therefore make number as 10110 100 1 adding zeroes 100 100 therefore number is 1100 I am not sure of the method.i

Re: [algogeeks] Google Interview Question

2011-05-27 Thread wujin chen
@radha, i think your solution is wrong. for this case: 101,10 in your solution , the ans is 10101,but the max ans is 10110. 2011/5/27 radha krishnan > 10100 is max ans > okay > convert the numbers to strings and sort based on the first character > !!! > if equal do that recursively and the

Re: [algogeeks] Google Interview Question

2011-05-27 Thread adityasirohi
how about this case: 9, 100 -> 9100 100 9 9100 2, 3, 9, 78 --> 78 9 3 2 9 78 3 2 I guess solution should be:- sort the array of numbers in an ascending order and then check for the first element in the array, if there is any other element greater than it, shift all the elements one right and

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
10100 is max ans okay convert the numbers to strings and sort based on the first character !!! if equal do that recursively and then if length is less give that preference !! i think this solution .. may be this is wrong !! On Fri, May 27, 2011 at 7:07 PM, wujin chen wrote: > @Piyush, how t

Re: [algogeeks] Google Interview Question

2011-05-27 Thread wujin chen
@Piyush, how to deal with this case :100 , 10 2011/5/27 Piyush Sinha > we can work out if we sort according to the leftmost integer > > On 5/27/11, adityasir...@gmail.com wrote: > > are you kidding me. Just simple sort wont work. > > > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > > rad

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
Haha !! Any counter case against sort ? ?? ? :P On Fri, May 27, 2011 at 7:02 PM, wrote: > are you kidding me. Just simple sort wont work. > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > radhakrishnance...@gmail.com> wrote: > >> sort :) >> >> >> On Fri, May 27, 2011 at 6:57 PM, ross wro

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Piyush Sinha
we can work out if we sort according to the leftmost integer On 5/27/11, adityasir...@gmail.com wrote: > are you kidding me. Just simple sort wont work. > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > radhakrishnance...@gmail.com> wrote: > >> sort :) >> >> >> On Fri, May 27, 2011 at 6:57

Re: [algogeeks] Google Interview Question

2011-05-27 Thread adityasirohi
are you kidding me. Just simple sort wont work. On Fri, May 27, 2011 at 9:31 AM, radha krishnan < radhakrishnance...@gmail.com> wrote: > sort :) > > > On Fri, May 27, 2011 at 6:57 PM, ross wrote: > >> Hi all, >> >> Given an array of elements find the largest possible number that can >> be formed

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
sort :) On Fri, May 27, 2011 at 6:57 PM, ross wrote: > Hi all, > > Given an array of elements find the largest possible number that can > be formed by using the elements of the array. > > eg: 10 9 > ans: 910 > > 2 3 5 78 > > ans: 78532 > > 100 9 > > ans: 9100 > > -- > You received this message b

[algogeeks] Google Interview Question

2011-05-27 Thread ross
Hi all, Given an array of elements find the largest possible number that can be formed by using the elements of the array. eg: 10 9 ans: 910 2 3 5 78 ans: 78532 100 9 ans: 9100 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-10 Thread Senthil S
Hello Anders Ma .. for inputs like "iiestseig" (just a random string) your code will not produce the correct output .. cos the best possible way to split these strings is {"i","iestsei","g"} .. But your code will produce {"ii","este","i","g"} as output .. so when there are overlapping palindromes y

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread Anders Ma
#include #include int is_palindrome(char* string, int start, int end) { int i = start, j = end; while (start <= end) { if (string[start++] != string[end--]) return 0; } /* print */ printf("[%d,%d] ", i, j);

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread oldman
I agree with Anders Ma's point,but in my opinion, using goto is risky in a import interview On Tue, May 10, 2011 at 9:52 AM, Anders Ma wrote: > sometimes we need goto, goto is not so evil. > > On Tue, May 10, 2011 at 2:49 AM, Manjeet Chayel > wrote: > > Dont use goto... its not good to have it

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread Anders Ma
sometimes we need goto, goto is not so evil. On Tue, May 10, 2011 at 2:49 AM, Manjeet Chayel wrote: > Dont use goto... its not good to have it. > > On Mon, May 9, 2011 at 2:44 PM, Anders Ma wrote: >> >> #include >> #include >> >> int is_palindrome(char* string, int start, int end) >> { >>    

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread Manjeet Chayel
Dont use goto... its not good to have it. On Mon, May 9, 2011 at 2:44 PM, Anders Ma wrote: > #include > #include > > int is_palindrome(char* string, int start, int end) > { >int i = start, j = end; > >while (start <= end) { >if (string[start++] != string[end--])

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread hary rathor
bro no company will accept your program with goto statement . -- 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..

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread Anders Ma
#include #include int is_palindrome(char* string, int start, int end) { int i = start, j = end; while (start <= end) { if (string[start++] != string[end--]) return 0; } /* print */ printf("[%d,%d] ", i, j);

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-06 Thread sourabh jakhar
On Fri, May 6, 2011 at 4:23 PM, sourabh jakhar wrote: > You are given a large string. You need to cut the string into chunks such > that each substring that you get is a palindrome. Remember that each 1 > length string is always a palindrome. You need to find the minimum number of > cuts that you

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-06 Thread sourabh jakhar
On Fri, May 6, 2011 at 4:23 PM, sourabh jakhar wrote: > You are given a large string. You need to cut the string into chunks such > that each substring that you get is a palindrome. Remember that each 1 > length string is always a palindrome. You need to find the minimum number of > cuts that you

Re: [algogeeks] Google Interview Question

2011-01-05 Thread MOHIT ....
may be use of double free ..? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more opt

Re: [algogeeks] Google Interview Question

2011-01-05 Thread Umer Farooq
There might be some error in calculating the value of some variable(s) which might be used to retrieve elements in some arrays/maintaining stack/linked list or any other data structure that uses the value of that variable to retrieve information from memory. Carefully checking the values of variab

[algogeeks] Google Interview Question

2011-01-05 Thread bittu
You have a stream of infinite queries (ie: real time Google search queries that people are entering). Describe how you would go about finding a good estimate of 1000 samples from this never ending set of data and then write code for it. -- You received this message because you are subscribed to the

Re: [algogeeks] Google Interview Question

2011-01-05 Thread juver++
Corrupted stack - buffer overflow. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For mor

Re: [algogeeks] Google Interview Question

2011-01-05 Thread MAC
dangling pointers ?? maybe.. also corrupted heap On Wed, Jan 5, 2011 at 4:46 PM, bittu wrote: > You are given a the source to a application which is crashing when > run. After running it 10 times in a debugger, you find it never > crashes in the same place. The application is single threaded,

Re: [algogeeks] Google Interview Question

2011-01-05 Thread ADITYA KUMAR
since it crashes at different places each time when it runs so there must be some problem which is not related to syntax there shud be some logical errors in code On Wed, Jan 5, 2011 at 4:46 PM, bittu wrote: > You are given a the source to a application which is crashing when > run. After runnin

[algogeeks] Google Interview Question

2011-01-05 Thread bittu
You are given a the source to a application which is crashing when run. After running it 10 times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you

Re: [algogeeks] Google Interview Question

2010-12-28 Thread Terence
@ pacific: Also consider the choice of flipping the node itself. And if an internal node cannot be flipped, it is still possible to flip its value, only the above choice is not taken into consideration.. On 2010-12-28 13:27, pacific pacific wrote: here is my approach : Starting from the root

Re: [algogeeks] Google Interview Question

2010-12-27 Thread pacific pacific
here is my approach : Starting from the root node , if root node need to have a 1 ... if root is an and gate : flips = minflips for left child to have value 1 + minflips for the right child to have value 1 else flips = minimum of ( minflips for left child to have value 1 , minflips for

Re: [algogeeks] Google Interview Question

2010-12-27 Thread Anand
@Terence. Could please elaborate your answer. Bottom up level order traversal helps to get the final root value but how to use it to find minimum flips needed to Obtain the desired root value. On Fri, Dec 24, 2010 at 1:56 AM, Terence wrote: > Using the same level order traversal (bottom up),

Re: [algogeeks] Google Interview Question

2010-12-24 Thread Terence
Using the same level order traversal (bottom up), calculating the minimum flips to turn each internal node to given value (0/1). On 2010-12-24 17:19, bittu wrote: Boolean tree problem: Each leaf node has a boolean value associated with it, 1 or 0. In addition, each interior node has either a

[algogeeks] Google Interview Question

2010-12-24 Thread bittu
Boolean tree problem: Each leaf node has a boolean value associated with it, 1 or 0. In addition, each interior node has either an "AND" or an "OR" gate associated with it. The value of an "AND" gate node is given by the logical AND of its two children's values. The value of an "OR" gate likewis

Re: [algogeeks] Google interview question

2010-12-14 Thread sourabh jakhar
i have a one idea in my mind is to implement a hash table structure based on 26 alphabets and a data structure of words. struct word { int info; char a[n]; }; structure contains the info about the word and an array in which document it is present or not out of n ex if it is word is mnnit and it i

[algogeeks] Google interview question

2010-12-13 Thread GOBIND KUMAR
One of my friends attended google interview.This was one the question asked. "you are given N documents(possibly in millions) with words in them. design datastructures such that the following scenarios take optimal time: a. print all the the docs having a given word b. print

Re: [algogeeks] Google Interview question

2010-11-30 Thread LALIT SHARMA
according to my understanding... Least sqaure regression line concept can be used.. as it would be the line ..that has minimum deviation from all the points in space. On Tue, Nov 30, 2010 at 9:48 PM, Prims wrote: > Given n points of structure > struct point > { > double x; > double y; > }; >

[algogeeks] Google Interview question

2010-11-30 Thread Prims
Given n points of structure struct point { double x; double y; }; Your function should return two points which are present on a line passing through maximum number of these n points. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

[algogeeks] Google Interview Question

2010-09-18 Thread bittu
@ Anil kumar S.R. wait yarr i have busy schdule..and forgot last time but i advise u to just put ladder and snake desgin infront of you u and chk the code.u will definetly get it. 1. Given a set of shapes in 2D space, and a coordinate pair, write a routine that returns true if any of the shapes

[algogeeks] Google Interview Question

2010-09-14 Thread bittu
how to decrypt a dictionary and how multithreading can help make the process faster -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

  1   2   >