why space complexity is O(1).

# Space complexity

**trilok-kumar**#2

because,here space(memory) taken only by two variables ‘a’ and ‘b’. it doesn’t depend on the input size(N)

Here the assignment of int a = 0, b = 0; happens only once and inside the loop a and b values are just been replaced so the space of the a and b remains the same as we are just replacing it. If we would have pushed into a list and as the list gorws with the loop then the space complexity would have been O(n).