???
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...
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
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,
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
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
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,
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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...
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
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
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
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
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
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
27 matches
Mail list logo