ashish.cooldude007
BAN USERatoi(char *s){
int no=0;
int i=0;
while(*(s+i)){
no=no<<3+no<<1+*(s+i);
i++;
}
logic:=take first no of string and shift by 10 (8+2)
solution of s is best..what happen in case when two odd numbers are there..
- ashish.cooldude007 August 22, 2010what does vertex mean in this q..I think i am misinterpreting this question.
- ashish.cooldude007 August 22, 2010suppose array is a1,a2,,an
we want to rotate with k index..a1 to ak is A and ak+1 to an is B;
reverse(A)(B);
(A)reverse(B);
reverse(AB);
example
2 3 4 5 6 7 8 9
k=4;
5 4 3 2 6 7 8 9
5 4 3 2 9 8 7 6
6 7 8 9 2 3 4 2
we will use max-heap or min heap..I am confused bcuz as a new data come and we take minimum of that(heap) and next is larger then we can remove lowest in heap. and insert it in heap of k.And again find minium and so on
- ashish.cooldude007 August 21, 2010let we are to sort data of 900mb data and we have memory of 100 mb then to sort this data first we divide 900mb data in parts of 100 mb.and we sort(quick sort) each part one by one..so there will be 9 parts after sorting these 9 parts we take 10-10 mb data from each 100 mb and merge that data with merge sort..
so totally 9+10 r/w operation will be there
Correct me if i am wrong
two link list A and B..if we can modify link list then it will become quite easy task
add flag value to each node and when we traverse link list A then make flag =1 and second time when we traverse link list B if we already find flag =1 then that will be interaction point
correct me if wrong
LCA is a binary search tree (BST) is simple. For any nodes x and y, the LCA is the first node which lies between x and y starting from root.
Node getLCA_BST(Node root, Node x, Node y):
Node curr = root
while !(x < curr && curr < y): // x.value < curr.value
if curr < x && curr < y:
curr = curr.right
else: //x < curr && y < curr
curr = curr.left
return curr // assume x and y are in the tree
ya its o(1)....it was misprinted i think
- ashish.cooldude007 June 30, 2010hashing ..choose a hash function for keys and map on hash table and as duplicate come in array countr will be increase ..so we can get duplicates
- ashish.cooldude007 June 30, 2010then we can do it easily by making a array and storing no of 1's as count and can get max no ..
- ashish.cooldude007 June 30, 20101 1 1 1 0 0 0
1 1 0 0 0 0 0
1 1 1 0 0 0 0
1 1 1 1 1 0 0
in this case should be ans is 3(index 0)???
I didnt get the question.what exactly you mean...if linklist are sorted then intersection can be removed but in case of not knowing the previous element before intersection point how can you merge these two.?
- ashish.cooldude007 August 27, 2010