here it is asked to solve the problem in o(1) extra space …so can’t we use recursion in this problem as it will require an extra space of o(n/k) …
and can you please xplain me space complexity of my code … am a bit confused
here it is asked to solve the problem in o(1) extra space …so can’t we use recursion in this problem as it will require an extra space of o(n/k) …
and can you please xplain me space complexity of my code … am a bit confused
yeah u cant use recursion .
it is O(n/k + n )
n/k becuase total n/k function call will be there . + n becuase becuase using k size stack to reverse in each function call so k * (n/k) = n
can u please send the most optimized solution of above problem with o(1) extra space