Hi all,

I have a small clarification on the problem CHEFSTEP ( https://www.codechef.com/problems/CHEFSTEP ).

It is a trivial problem which can be solved in O(N) time. We have to perform just the mod operation for N numbers (in each test case).

I first choose to solve it by just taking one integer at a time as input, processing it, and printing the output (which takes O(1) space complexity).

But when I do this I get TLE.

The same logic, if I input all the N elements in a array first completely, and process it for generating output, I got the solution accepted in 0.36 seconds.

So this takes O(N) space complexity.

Though both take O(N) time, the first solution (TLE) is more space efficient, but still TLE.

Can anyone help me please.

**wrong answer(TLE)**

https://www.codechef.com/viewsolution/36045766

**correct answer(AC)**

https://www.codechef.com/viewsolution/36045643