Domanda di colloquio di Amazon

Array related problem. easily found in previous question papers.