Doubt in my code

Hello, here is my code :

What is the requirement of the if condition in the function removeChar ( ). For the clarity I have marked that in my code by commenting out my doubt in front of the if statement.

hello @yashsharma4304
if we have string of length 0 or 1 then its obvious that it does not contain duplicate .
thats is the only reason why we have that if condition there in the code

In this case we have simply write :
return;

But what it will returning ?
And in case I am not using that condition then also it is giving the same results for these two cases

we are returning nothing (void) becuase array is passed as pointer so whatever changes we will make in array it will be reflected in original array so no need to return anything

yeah adding that condition will not have any impact on answer but its good habit to handle corner case seprately.

1 Like

Ok. Thanks for clearing my doubt :relaxed:.