raghu.slp
BAN USER- 0of 0 votes
AnswersGiven two arrays : arrivals and departrues array
- raghu.slp
arrivals[i] -- arrival time of flight i
departures[i] -- departure time of flight i
when a flight arrives at the airport, you have to provide a stair case to the flight
and when it leaves you can take it back.
find the min number of stair cases required.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersInteger has been represented in linked list. Eg. 7541 has been represented as 7->5->4->1 with 4 nodes each having a digit. Given 2 such linked lists, you need to compute the sum of them.
- raghu.slp| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere are n petrol bunks arranged in circle. Each bunk is separated from the rest by a certain distance. You choose some mode of travel which needs 1litre of petrol to cover 1km distance. You can't infinitely draw any amount of petrol from each bunk as each bunk has some limited petrol only. But you know that the sum of litres of petrol in all the bunks is equal to the distance to be covered.
- raghu.slp
ie let P1, P2, ... Pn be n bunks arranged circularly. d1 is distance between p1 and p2, d2 is distance between p2 and p3. dn is distance between pn and p1.Now find out the bunk from where the travel can be started such that your mode of travel never runs out of fuel.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersMerging 2 binary trees.
- raghu.slp| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an m-ary tree, need to implement two functions lock and unlock on a node n. You can lock a node if none of the nodes in its subtree is locked and none of its ancestors are locked. Unlocking a node should release the lock. Suggest a good data structure for solving this. And implement the lock and unlock functions in O(log n) time.
- raghu.slp| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
Answersconsider 1,2,3,4,5,6,..... infinite ...
- raghu.slp
intialize
jump=2.
then 2,4,6,8 .... gets removed.
remaining: 1,3,5,7,9,11 ...
jump=3.
then 5,11, ... gets removed.
reamining: 1,3,7,9,13,15 ..
we carry on for jump infinitely. here 1,3 are 'blessed' as they will not be removed.
now,given a number 'n', propose a algorithm to find out weather it is a blessed number or not.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
looked for both the cases, didn't like the idea of sorting a a file with huge number of integers, that itself was another question.
- raghu.slp May 24, 2010