Re: [algogeeks] Re: determine if a string if of form pZq

2012-04-24 Thread Siddhartha Banerjee
???
if you meant that the string should be of the form pZq where p=q(inverse) ,
where p,q can only be X or Y,
then the simple way would be to see if the first and the last character are
same and equal to X or Y or not!!!

but i am sure there is more to this question, it cannot be that simple...

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Given an array A[1..n] of log n bit integers, sort them in-place in O(n) time

2012-04-04 Thread Siddhartha Banerjee
if the length of the binary representation of elements is logn, then the
elements themselves are of size less than 2^log(n)=n.
as all the elements are less than n, use counting sort!!!

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: remove duplicates

2012-03-18 Thread Siddhartha Banerjee
in a string... yes, because there are only 256 possible characters (or
65536, in case of unicode), so just create a boolean array of length 256
initialized to false and whenever a character occurs make the corresponding
element true. While scanning the string, if an element has already
appeared, delete it.

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] thanx to all

2012-02-29 Thread Siddhartha Banerjee
congrats yaar!!! share your interview experience please!!!

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: array problem

2012-02-16 Thread Siddhartha Banerjee
convert the numbers into base k... and do bitwise addition of numbers, where
bit(a)+bit(b)=bit(a+b)mod(k)
of you convert all the numbers into base k and add them bitwise in a
variable say x, then the numbers occuring nk times vanish, and the final
result stored in x is a+a++a(b times) where a is the number repeating b
times...
next time go through the array again and see whether any number when added
with itself b times gives the same result as x, if yes, out put that number.

I had seen a solution to a problem where in an array of size 3n+1, each
element except one repeating thrice, we need to find the non repeating
element in O(n) time O(1) space, i tried to generalize the proof to fit
this case...

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: check Similar array

2012-01-09 Thread Siddhartha Banerjee
create AVL tree using elements of array 1... with each node of AVL tree
maintain a count variable...
if an element occurs more than once,increment the count... (this step is
not compulsory though,we can simply insert the new element in tree)
go through the second array,for each element in array, find the element in
AVL tree (if not found then arrays are not same)
delete the corresponding node (or decrement the count if maintianing
it)...finally the AVL tree should not have any element left..

O(nlogn)

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Facebook interview question.

2012-01-09 Thread Siddhartha Banerjee
does this work if array elements are negative???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] coding round question

2011-10-30 Thread Siddhartha Banerjee
could you please explain the question in a bit more detail?
especially the partThere are some particular
numbers which are made using 4 or 7 : any combination of 4 and 7 are
accepted.

from what i understand of the question, there are some intervals given...
we can move the intervals left or right by one unit, any such movement
counts as one move... we have to move the segments in such a way that it
maximizes the maximum number of segments where a number can lie...the
maximum number of moves allowed are given... is that true???

by the way, which company's coding round was it???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Searching In a large file

2011-10-27 Thread Siddhartha Banerjee
read the question guys, only 2 mb of memory...
i would perhaps try to find the range of the numbers... say the range is 300
million here...
so i would maintain a count array, count[i]+=1 if on traversing the large
file i find a number from chunk i, here chunk can be decided suitably, for
example ith chunk means all numbers occuring between 1i and
1(i+1)... (chunk size decided upon the size of the RAM)... then suppose
each chunk should have say 5000 elements, so each count should have 5000
elements... suppose the jth count variable has less than 5k elements... so
on the nest pass, i will maintain a 1 element bit array, and set
correcponding bit to 1 if the number is found in the file... after going
through the bit array once, we can find the desired number...

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: FACEBOOK ONLINE CODING ROUND

2011-10-24 Thread Siddhartha Banerjee
the contests are over... this was a question asked in a college...
but now that you have already written such an awesome code, would you mind
sharing it??? or atleast the algorithm of your code???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: finding anagrams in file

2011-10-22 Thread Siddhartha Banerjee
how about this O(nm) solution?
first create a 26 length int array
for each word, store the number of times each character appears in the word,
in the above 26 length array O(m)...
Insert this value in a trie (insertion=O(m))... example if the sorted string
contains a-4times, b-3 times, c-2 times, d 5 times, then store
bbbccd in the trie...
while inserting in the trie, if the values repeat, then it is an anagram...

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Inplace Array Convertion

2011-10-14 Thread Siddhartha Banerjee
if integers are positive,then go  on a cycle... like a[2]goes to its final
position, the  element in a[2]'s final position goes to its final position,
and so on... each time  on visiting an element, put some marker on it...
like make it negative... finally after an element comes to position of a[2],
search the array from a[2] onwards to see if any element is unmarked... if
there is one, then go on a cycle from that element onwards and proceed...
till you visit all element of array... finally change the sign of all
elements to positive (remove the markers...)

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Needed recursive sol

2011-10-01 Thread Siddhartha Banerjee
there must be a non brute force approach too rite???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: THANX ALGOGEEKS !!!!!!

2011-09-21 Thread Siddhartha Banerjee
share  the questions for the group!!! and congrats and thanks in
advance...:

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c output

2011-09-19 Thread Siddhartha Banerjee
on running,every time i get  second a=30... any reasons for that???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] A logical Question

2011-09-15 Thread Siddhartha Banerjee
it will decrease... initially suitcase was removing water equal to its
weight, now it displaces water eual to its volume... as  density of suitcase
is more than that of water (assumption) so the water level decreases...

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-09-15 Thread Siddhartha Banerjee
sort all elements :nlogn
If the last 2 arrays are B and C, then sort elements of the form
(bi+cj):O(n^2) time O(n^2) space
[for the above step, smallest element  in  b1+c1,next element is smaller of
(b1+c2) and(c1+b2), increase pointer accordingly.  If at one step, the
element under consideration is bi and cj, then the next smallest element is
min(bi+c(j+1),b(i+1)+cj) ]
for each element in A, see if corresponding element is there in [B+C]
O(nlogn)
If yes, then search for  the corresponding two elements in array B and C
O(nlogn)

total time O(n^2), space = O (n^2)

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] arrays in c

2011-09-03 Thread Siddhartha Banerjee
how does compiler internally store the fact that a points to an unmodifiable
lvalue, and also it's size???
where are the normal pointer variables stored??? (stack region, heap region,
data segment???)
and the array pointer variable and it's range???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Need algorithm asap

2011-09-03 Thread Siddhartha Banerjee
please check out the code,  doesnt give right solution on running...
or perhaps i missed something... how should you call your function? if array
is a={1,2,3} you call from main function as
bipartition(a,0,2), right???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MICROSOFT

2011-09-03 Thread Siddhartha Banerjee
perhaps we can make it O(mlogm), m= no of distinct elements... just create a
hash table and store the count of the number of time elements occur... O(n),
now sort the m elements and proceed as above...
it is obviously not possible to do it faster than O(mlogm), where m = no of
distinct elements...
so order = O(n+mlogm)=O(mlogm)(???, assuming m!n)

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Need algorithm asap

2011-09-02 Thread Siddhartha Banerjee
no of valid bipartitions are 2^n, thats what he meant I guess... ( if you do
not want null set as one of the partitions then subtract 1 from answer...)

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Find Max Sum Value Pairs

2011-09-02 Thread Siddhartha Banerjee
yeah piyush's solution seems correct to me... if current amx is from
a[i],b[j], then next maximum can only be either of a[i-1],b[j] or
a[i],b[j-1] continue!!!

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] stack interview question

2011-08-31 Thread Siddhartha Banerjee
couldn't get it... what are the sequences given in options??? are they the
pushed values or popped values or what???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Amazon - Interview Qn

2011-08-31 Thread Siddhartha Banerjee
this takes O(n^2) time right??? because we interchange 1st and nth node
datas...
then we can go to 1st node- next node... but is there any efficient way to
find the pointer of the (n-1)th node??? (without traversing from the
beginning, as it takes O(n^2) time if we have to traverse from beginning to
get the last node to be found...
Also I am assuming O(1) space, so storing the pointers in an array doesnt
help...

In short, is there any O(1)space and O(n) time solution?

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: APTITUDE QUESTIONS

2011-08-31 Thread Siddhartha Banerjee
i couldnt get the first question... for any perfect cube... the cube root is
an integer, in any base... for example, the cube roots of 1,8,27,81,125,
etc... will be integers in base 10, and integers in base 10 are integers in
any other base... so am i missing something here???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: loop in link list

2011-08-31 Thread Siddhartha Banerjee
how can head2-next be null in a linked list witha loop???
i mean it would just go around in circles right???

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.