KPIT Technologies interview question

Data structure logic based on example of alternate squares