DEV Community

Discussion on: How To Solve Missing Number Problem In Java, An Amazon Interview Question

 
ggorantala profile image
Gopi Gorantala

Yup.. the key is xor. Functional programming is quite fun. I got interviewed at Amazon last December, I was asked to implement a longest connected nodes for a binary tree.. it was easy and I did it using iteration first, she asked me to go for recursion and I did. next, she asked me to try with another approach. So the point is, if you implement the solution one way, they tweak it ask you for some other cases, what if that and what if this happens on the writtten algorithm. The point is, we need to train our brain for all possible solutions and optimize them 😉