Thoughtworks interview question

Array Related, Solving the given problem with OOPs Concept