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
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
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
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
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
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
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
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
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:
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
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...
--
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
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
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 :
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
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
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];
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
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.
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
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.
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
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
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
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,
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
@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
@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
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
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
@ 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
@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
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,
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
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
@ 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 ??
--
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
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
@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
@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
@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,
@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
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
@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
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
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
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
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
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
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
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,
@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,
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
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
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
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
@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
@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
@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 • » νιρυℓ « •
@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
@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 +=
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;
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
@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
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
@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
@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
@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:
@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
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
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
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
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:
#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] ,
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
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
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
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
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
@ 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
@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
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
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
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
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
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
@ 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
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
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
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
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
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
@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[] )
{
@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.
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)
{
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
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
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
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
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
100 matches
Mail list logo