Naveen Reddy Mandadi
BAN USER- 3of 3 votes
AnswersThere are exactly N advertising boards on the highway. Now a company want to advertise on some of these advertising boards (each advertising board costs some money).
- Naveen Reddy Mandadi in United States
Company strategy is that, they want at least 'K' advertisement should be there among M consecutive advertising boards. But at the same time Company want to pay minimum for its advertisement.
Now, what is the total number of ways Company can advertise meeting its minimum cost strategy.
Also 1 <= K <= M <= 50 and M <= N <= 10^9
As for Example: N = 3, M = 2, K = 1 ==> there is only one way for minimum cost, ie. 0C0 , where '0' denotes No company advertisement, and 'C' denotes company advertisement board.
Similarly, for N = 4, M = 2, K = 1 ==> there are 3 possible ways, ie. C0C0, 0C0C, 0CC0.| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 0of 0 votes
AnswersManage n queues in a given memory.
- Naveen Reddy Mandadi in India
Support below operations on queues.
//initialize n queues in memory m of size s
//queues will be identified with numbers from 0 to n-1
void initialize(void* m,int s,int n);
//enqueue object o into queue identified by q
//as long as there is free memory this should be successful
void enqueue(int q,Object o);
//dequeue an object from queue identified by q
Object dequeue(int q);
Give the best solution such that there will be minimum relocation of queues| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Algorithm - 0of 0 votes
AnswerDesign a system for the customer to review a product. It should be able to incorporate web-services. Describe the entire flow from the client to the database.
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Computer Architecture & Low Level Data Structures Application / UI Design - 0of 0 votes
AnswersConvert binary search tree to doubly linked list
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersGiven list of words in the order as in the dictionary, find the order of the alphabets.
- Naveen Reddy Mandadi in United States
Suppose you are given words in the same order as in the dictionary like a, ant, ball, cat, do, dog, fog, frock etc.
From these words you know that there are alphabets a, n, t, b, l, c, d, o, g, f, r, k.
You don't know the order of these alphabets before hand.
You will have to find the order of these alphabets based on the order of the given words.
From a and ant you cannot make out anything.
From ant and ball you can make out that a comes before b in the order.
From ball and cat you can make out that b comes before c in the order.
From cat and do you can make out that c comes before d in the order.
From do and dog you cannot make out anything.
From dog and fog you can make out that d comes before f in the order.
From fog and frock you can make out that o comes before r in the order.
From these clues you should make out the order of the alphabets.
Not necessarily you will be given all the dictionary words, but the words which are sufficient enough to make out the order of the alphabets.
You can always say you cannot make out the order if the words given are not sufficient.| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersRemove all two zeros in the given string.
- Naveen Reddy Mandadi in India
Example: a3409jd00dk000d
Output: a3409jddk000d
Note: If there are less/more than two zeros consecutive, it should not be replaced.| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Algorithm - 0of 0 votes
AnswersMultiply two large integers represented in char array.
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Algorithm - 0of 0 votes
AnswersFind level wise linked lists in a BST.
- Naveen Reddy Mandadi in United States
Example: 1 has children 2 and 3
2 has children 4 and 5
3 has children 6 and 7
6 has children 8 and 9
then the algorithm should give the below
result[0] = 1
result[1] = 2->3
result[2] = 4 -> 5 -> 6 -> 7
result[3] = 8->9| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersFind common ancestor of two nodes which has least value.
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersThere are n nodes with a value in each node.
- Naveen Reddy Mandadi in United States
Communication between two nodes can happen any time to pass the node value from one to the other, every communication takes 1 second.
Whenever communication happens from node a to node b, node b's value can be changed based on node a's value.
One node cannot participate in communication to two other nodes at any point of time.
At any point of time each node can hold only one value.
We need to end up with "sum of the values in all the nodes" as the value in all the nodes, how much time is required?| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersReverse double linked list
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 0of 0 votes
AnswersMerge two sorted arrays
- Naveen Reddy Mandadi in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm
Traverse to the new root node.
if new root node is left/right of its parent, make left/right node of its parent NULL.
Now insert old root node into new root node, which is O(logn).
I too think so, but i do not know if that is correct.
- Naveen Reddy Mandadi June 25, 2012Hashing is ideally O(1).
Copy happens only once, so that would make it O(n)+O(n), which is still O(n).
I think the files are already sorted based on access time and the resulting merged file should be sorted on access time as well.
- Naveen Reddy Mandadi April 05, 2012Should the hopping happen only in 1 direction or it can happen in both directions?
Should a position which is already hopped to can be hopped again, otherwise there can be infinite number of hops?
Before returning, all the elements in DQStack should be put back to EnQStack
- Naveen Reddy Mandadi April 05, 2012
We would need 4.
- Naveen Reddy Mandadi August 12, 2012For a list of size n, we would need at least n-1 comparisons.
Every element has to be compared at least once, nothing better than this can exist.
If we use quick sort until we end up with pivot as the median element the complexity on average would be O(n).