VMWare challenge on HackerRank
01 Nov 2014Recently I appeared for the VMWare pre-interview Evaluation challenge on HackerRank. There was only one question to solve in the given 90 minutes. The question was as follows:
The solution didn't clicked me then, but this is what I came up with. Not the most efficient solution, but it works.
Note: I haven't considered the case where all inputs are passed as 1 and no flipping is done (Ambiguity, not mentioned in the question). Also in the inputs you only pass the array not the size. If you want to pass size as well then add an if condition where if i is zero then parseInt into a size variable and in else the array.