DEV Community

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

Collapse
 
jonrandy profile image
Jon Randy 🎖️

I somehow don't think you're going to be penalised for using stuff like map, filter, and reduce - these are pretty much cornerstones of functional programming

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

I would actually look down upon a candidate reinventing any of the above methods, as the resulting code would likely be less efficient - and they've also demonstrated a lack of knowledge of the language.

The key here is the XOR stuff... the loops and other things are just fluff.

Thread Thread
 
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 😉