Andy2000
BAN USER- 1of 1 vote
Answersdesign Malloc Function which user can call and get the allocation. For example, there is a Byte array of byte[1000] so if use call getAllocation(3) then we will assign 3 bytes to user. and again if another user call getAllocation(100) then we will assign again,
- Andy2000 in United States for STB| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersWrite an algorithm to insert a new value into a circular sorted linked list.
- Andy2000 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersInterview Question – how to improve a parallel cache, this is the most difficult question i got. I had no idea what the interviewer meant and he clearly had some 'right' answer in his mind, but no clue.
- Andy2000 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow would you store 1 million phone numbers?
- Andy2000 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 2 votes
AnswersOn a 2-D grid, the positions (x,y) of 3 persons are given. Find the meeting point such that sum of distances of each person from meeting point is minimized.
- Andy2000 in United States
Now generalize this to N persons and solve.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersDesign Chess Game. asked me this in testing interview.
- Andy2000 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersYou have a circular Linked List:
- Andy2000 in United States
a->b->c->d->e->c
Find where the cycle is starting| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Linked Lists - 1of 1 vote
AnswersYou have 2 sorted Arrays. A and B. A is shorter than B. B has few elements in sorted order and has space for all elements of A. Now Merge these both array so that All elements are sorted. You cant use extra Array. Use Only Array B.
- Andy2000 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays
Cool!! Good to learn new thing. This was the only question given. I was thinking to solve it by taking meddle in 2D Matrix. and then find. Since from middle element, it could be the shortest path if 3 People are scattered very widely.
I think here we will go for Manhattan distance.
I think your approach is good but have high complexity.
According to you, here is what I think:
1) Push 2 numbers in stack.
2) Now calculate (Based on operator precedence) all possible numbers push these in stacks
3) now pick the next number from an Array and again generate all possible numbers from the numbers already pushed into stack. Now we need to store these numbers in new stack.
4) we will break the loop as soon as any number is reached to the result and count = n-1.
I know this is not efficient solution since we are declaring lots of stacks and calculating all combinations.
Anyone knows any better solution please let us know.
Thanks
Permutation(Int[] array, recLength, n)
if(recleng == n)
{
list<int[]> permutation = new list<int>();
permutation.add(array);
}
for(int i= recLegn, i <n; i++)
{
swap(int[i], int[recLen])
permutation(array, k+1, n)
//BackTrack
swap(int[i], int[k])
}
Once this is done, Sort the list and print it.
- Andy2000 September 02, 2012Here is what I think:
1) First check length of A+B = C if true then
2) Decide which string A or B has First character in C, Both A and B are same then continue traversing C until we find Unique element. Hence we can find which string is the first one.
3) Now we know that string interleaving is starting from first string so we can continue scanning second and then first by taking turn.
There are 2 ways:
1) Calculate Mid Point of Linked list for which you would traverse the entire LL and then that Mid point will be Root. Left elements of LL will be left child and Right will be right child.
After that repeat the same cycle for Left LL and same for Right LL. This has more run time since this will have cost of traversing LL and finding Mid elements.
2) In second approach, we are are good with space complexity, then we can just read all elements of LL into an array and then construct the tree. Finding mid element in an array is just O(1) so that will save time. And then we can construct the tree.
Good code. For other folks. Here is the binary representation of few numbers:
- Andy2000 September 04, 2012binary: 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = 10 1011 = 11