[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

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 monish.gup...@gmail.comwrote: 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

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

2013-06-09 Thread Avi Dullu
Read up on Interval trees http://en.wikipedia.org/wiki/Interval_tree. 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 insight

[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

[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

Re: [algogeeks] Google Interview Question

2011-10-01 Thread arvind kumar
Hi Are u attending off-campus or on-campus interview? On 10/1/11, R@TH!$H rathishkan...@gmail.com 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

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 arvindk...@gmail.com wrote: Hi Are u attending off-campus or on-campus interview? On 10/1/11, R@TH!$H rathishkan...@gmail.com wrote: Hi, I am attending Google interview on Monday. Please help me with sample

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 rathishkan...@gmail.comwrote: off campus. -- RK :) On Sat, Oct 1, 2011 at 11:59 AM, arvind kumar arvindk...@gmail.comwrote: Hi Are u attending

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 deepakgarg...@gmail.com 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 rathishkan...@gmail.comwrote:

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 rathishkan...@gmail.comwrote: apply through google careers site... -- RK :) On Sat, Oct 1, 2011 at 2:02 PM, Deepak Garg deepakgarg...@gmail.comwrote: hey,,,what is the process of attending google

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 deepakgarg...@gmail.com wrote: hey can pls share the link. thnks On Sat, Oct 1, 2011 at 2:04 PM, Rathish Kannan rathishkan...@gmail.comwrote: apply through google careers site... --

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 this

[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

[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 :

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 gupta.abh...@gmail.comwrote: 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

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;i2*n;i++) { On 1 August 2011 02:42, shady sinv...@gmail.com wrote: when was this question asked in Google ? approximate date ? position ? On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta

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;i2*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 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 gupta.abh...@gmail.comwrote: A is an

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 jalanha...@gmail.com 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.

[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

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 anand.shastr...@gmail.com 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.

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 anand.shastr...@gmail.com

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
if number is (131) -1 u declare a 2GB array ? On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri anand.shastr...@gmail.com 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

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 (131) -1 u declare a 2GB array ? On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri

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,

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 anshumishra6...@gmail.comwrote: @all go through this code

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

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

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 B iff A B B A Concatenate all elements in this order set. To show the correctness of this algorithm need to show that this

Re: [algogeeks] Google Interview Question

2011-05-30 Thread KRQ
but ,when the arr is 78 3 to add 0 78 30 sort: 30 78 ans:378? 2011/5/27 Logic King crazy.logic.k...@gmail.com i agree with piyush...can't find the countercase...satisfied with the algo. On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote: how about adding zeroes at

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

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 nav.coo...@gmail.comwrote: @ 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

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,

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

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

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 ?? --

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 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

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 agr.bhav...@gmail.comwrote: solution may be array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all exceptions ) then

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 Geeks

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 keym...@gmail.com wrote: @Sunny i explained how to deal with edgecases right after my post 1,

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 email

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 keym...@gmail.com 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

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

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, adityasir...@gmail.com 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

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

[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-27 Thread radha krishnan
sort :) On Fri, May 27, 2011 at 6:57 PM, ross jagadish1...@gmail.com 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

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 jagadish1...@gmail.com wrote: Hi all, Given an array of elements find the largest possible number that can

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 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

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, 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 PM,

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 ecstasy.piy...@gmail.com we can work out if we sort according to the leftmost integer On 5/27/11, adityasir...@gmail.com adityasir...@gmail.com wrote: are you kidding me. Just simple sort wont work. On Fri, May 27,

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 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

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 ecstasy.piy...@gmail.comwrote: 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

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 crazy.logic.k...@gmail.comwrote: i agree with piyush...can't find the countercase...satisfied with the algo. On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@Piyush Sinha, what about 9, 801 2011/5/27 • » νιρυℓ « • vipulmehta.1...@gmail.com 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 crazy.logic.k...@gmail.comwrote: i agree with piyush...can't find

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Aakash Johari
@vipul: try for 100 and 10 2011/5/27 • » νιρυℓ « • vipulmehta.1...@gmail.com @Piyush Sinha, what about 9, 801 2011/5/27 • » νιρυℓ « • vipulmehta.1...@gmail.com 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

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 aakashj@gmail.comwrote: @vipul: try for 100 and 10 2011/5/27 • » νιρυℓ « •

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 mrmittalro...@gmail.comwrote: @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

Re: [algogeeks] Google Interview Question

2011-05-27 Thread anshu mishra
@all go through this code #includeiostream #includealgorithm 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 +=

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 anshumishra6...@gmail.comwrote: @all go through this code #includeiostream #includealgorithm using namespace std; bool compare(int a, int b) { string u, v;

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 suprajasank...@gmail.com wrote: Hi Isnt this the Kadane's (largest subarray) problem ? Rgds Supraja J On Fri, May 27, 2011 at 9:41 AM, anshu mishra

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 ecstasy.piy...@gmail.comwrote: how about adding zeroes at the end of

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 • » νιρυℓ « •
@shubham, 10 101 ?? On Fri, May 27, 2011 at 11:41 PM, shubham shubh2...@gmail.com 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

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 shubh2...@gmail.com 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

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 ankitsamb...@gmail.comwrote: @shubam: won't work try following test case: 8,89,9 Ankit Sambyal On Fri, May 27, 2011 at 11:11 AM, shubham shubh2...@gmail.com wrote:

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 srajan.don...@gmail.comwrote: @ankit sambyal.i think d rite answer will be 9978 in dat case. On Fri, May 27, 2011 at 11:50 PM, ankit sambyal

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 your code wont

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

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 chayel.manj...@gmail.com wrote: Dont use goto... its not good to have it. On Mon, May 9, 2011 at 2:44 PM, Anders Ma xuejiao...@gmail.com wrote: #include stdio.h #include string.h int

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 xuejiao...@gmail.com wrote: sometimes we need goto, goto is not so evil. On Tue, May 10, 2011 at 2:49 AM, Manjeet Chayel chayel.manj...@gmail.com wrote:

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-09 Thread Anders Ma
#include stdio.h #include string.h 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] ,

Re: [algogeeks] GOOGLE INTERVIEW QUESTION

2011-05-06 Thread sourabh jakhar
On Fri, May 6, 2011 at 4:23 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 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

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 shashank7andr...@gmail.com 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

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 more

[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

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

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 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 technic@gmail.com wrote: Using the same level order

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

[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 likewise is

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

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

[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

[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
Write a function Brackets(int n) that prints all combinations of well- formed brackets. For Brackets(3) the output would be ((())) (()()) (()) () ()(()) ()()() -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

[algogeeks] Google Interview Question

2010-09-14 Thread bittu
Write a function Brackets(int n) that prints all combinations of well- formed brackets. For Brackets(3) the output would be ((())) (()()) (()) () ()(()) ()()() with explaination dat is at every call what is contant of stack during pushing and popping -- You received this message because you

Re: [algogeeks] Google Interview Question

2010-09-14 Thread TurksHead Education
Number of correctly matched pair of n parenthesis will be a catalan number Cn. You may want to see the application of catalan numbers at http://www.rawkam.com/?p=568 http://www.rawkam.com/?p=568 On Tue, Sep 14, 2010 at 8:27 PM, bittu shashank7andr...@gmail.com wrote: Write a function

[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

[algogeeks] Google Interview Question-Snake and Ladder Design

2010-09-13 Thread amit
Hi, can anyody tell how to approach these types of questions . This was asked in google interview that how would you design a Snake and Ladder Game. Which data will be private and all. If anybody can provide any links to any good tutorial then it would be helpful. -- You received this message

[algogeeks] Google Interview Question

2010-08-22 Thread bittu
@Arpit i think finding max second max does n't reuire to mach time as u have told n + log(n) -2 step check out my solution if i am wrong plz xplain me n + log(n) -2 step required to solve this problem public class array { public void getMax( double ar[] ) {

Re: [algogeeks] Google Interview Question

2010-07-15 Thread harit agarwal
@varun c should also be in the array -- 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.

Re: [algogeeks] Google Interview Question

2010-07-15 Thread umesh kewat
Hi, suppose we have given n distinct numbers are a[n]. 1. sort them using quick or any other sort in O(nlogn) 2. use then int find(int *arr, int n) /* return largest number if fing it otheriwse retirn 0*/ { int i,j,k, temp; for(k=n-1; k2;k--) { j = k-1 i=0; while(i!=j) {

[algogeeks] Google Interview Question

2010-07-14 Thread Debajyoti Sarma
An array contains the set of positive integer. Find the largest number c such that c=a+b where a,b,c are distinct number of the set? [Consider , reducing complexity] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Google Interview Question

2010-07-14 Thread Varun Nagpal
First attempt: sort them and add the 2 largest numbers 2nd attempt: find 1st and 2nd largest number and add them. On Wed, Jul 14, 2010 at 7:27 AM, Debajyoti Sarma sarma.debajy...@gmail.comwrote: An array contains the set of positive integer. Find the largest number c such that c=a+b where

Re: [algogeeks] Google Interview Question

2010-07-14 Thread siddharth shankar
O ( n^2 ) soln can be done step : 1 . sort array in n*log(n) . 2. for every C from last find two number A B such that A+B=C ... O( n^2 ) Total :- O(N^2) can we improve it further ?? any help please On Wed, Jul 14, 2010 at 10:57 AM, Debajyoti Sarma sarma.debajy...@gmail.com

Re: [algogeeks] Google Interview Question

2010-07-14 Thread Ashish Goel
sort using counting sort or quickselect now a and b are less than c so find c first suppose c's index is k the start two indexes i=0 and j=k-1, if a[i]+a[j] ==a[k] return these numbers, else add elements at i,j if the sum is greater than c reduce j, if less than c increase i alternatively sort

[algogeeks] Google Interview Question: find shortest summary containing all key words

2007-09-24 Thread Sticker
Declare: this question is originally from Google. The original form is: given a document, how to find a shortest summary containing all the key words. After translated, it will be: given a sequence, how to find a shortest substring that contains all the items required. Example: a sequence

  1   2   >