Misleading Problem Statement


#1

Here We are supposed to solve this question without using any string. But we can use integer variables.
Initially I thought that I need to do some inplace calculation without using any space at all.


#2

I agree. The solution uses extra space (storing the reverse).

Instead, the problem description should say do not use strings.


#3

Hi Ayush ,

The question is correct . Extra/Auxiliary space means you are going to use some of the data structure to store your data/input . As long as you are only using variables then it would be considered as constant space i.e. O(1) .

Hope you fond it useful.

Thanks


#4

Hi,

I would also say the question is misleading. It should have said “using constant space” or “using O(1) space”. Many other questions use this phrasing.

Saying “without extra space” where “extra” is to be inferred as a keyword meaning “non-constant function of n” is too much.