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

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

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,

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

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

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,

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

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

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

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

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,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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