Time limit exceeded-space time complexity

how to return 2 values from a function?

In C or C++, we cannot return multiple values from a function directly. So we get around this by using some tricks.

  1. if we want function to change value of two or more variables then we can pass the variables by address and make changes to the values stored at the address, effectively changing multiple values through a function.
  2. Say you want to return two values a and b we’ll declare the function that returns a vector, and then we’ll push the variables to the vector created inside the function and return the vector, so essentially you’ll return vector containing two values and you can extract them and use however you want.

Hey @itsexp_2302 I hope I have cleared your doubt, if so please mark the doubt as resolved else feel free to ask further.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.