Are you sure - it's constant space ? I can imagine O(k) space


#1

Are you sure - it’s constant space ?
I can imagine O(k) space.


#2

Yes, there is a solution possible using O(1) space. Think Binary Search.