thisandthat
BAN USER- 0of 0 votes
AnswersGiven input format, The first line has the number of employees of a company Z. The next two lines have employees to perform certain operations on. The first employee of the fourth line can be assumed to be the ceo of the company. Each line from then on has the format Employee X Employee Y where X manages Y. (and hence Y forms the child for X).
- thisandthat in India
input:
6
Rajesh
Ravi
//Tree Starts here
Ram Raj
Ram Goku
Raj Rajesh
Raj Richa
Richa Ravi
Its known that each person in the company can directly line manage a maximum of 2 other employees.
For the two employees in the first two lines, find the lowest common manager.
How to construct this tree in java to eventually do an lca?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 3of 5 votes
AnswersA robot has to move in a grid which is in the form of a matrix. It can go to
- thisandthat in United States
1.) A(i,j)--> A(i+j,j) (Down)
2.) A(i,j)--> A(i,i+j) (Right)
Given it starts at (1,1) and it has to go to A(m,n), find the minimum number of STEPS it has to take to get to (m,n) and write
public static int minSteps(int m,int n)
For instance to go from (1,1) to m=3 and n=2 it has to take (1, 1) -> (1, 2) -> (3, 2) i.e. 2 steps| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm
Corrected
- thisandthat March 10, 2015