Amazon Interview Question
0of 0 votesA very interesting question. Still awaiting answer so posting again.
What does this method do? Stuff is a object in java with two members someStuff and anotherStuff public static Stuff doSomeStuff (Stuff s0, Stuff s1) { Stuff someStuff = s1.getSomeStuff(); if(someStuff != null){ s1.setSomeStuff(doSomeStuff(null, someStuff)); } if(s1.getAnotherStuff()==null){ s1.setAnotherStuff(s0); return s1; } else { Stuff myStuff = doSomeStuff(s1,s1.getAnotherStuff()); s1.setAnotherStuff(s0); return myStuff; } }Does it have any bugs or edge cases where it will not execute?
Describe the time complexity of the function and comment on its effectiveness.
Country: United States

Think of Stuff as tree and somestruff as rightchild and otherstuff as leftchild. Now problem is easy :)
- Abhishek on June 22, 2012 Edit | Flag Reply