Invert an string is one of most common DSA problem required in interviews. But beyond working, it needs to be efficient, and efficient here means: Modifying the input array in-place with O(1) extra memory. O(n) time O(1) Space O(n) is a notation used to describe the time complexity of an algorithm. It indicates that the execution time of the code grows linearly with respect to the size of the input (n). If you have an array with n elements, an O(n) algorithm will have to perform a number of operations that is proportional to n. For example, if the array has 10 items, the computer performs (approximately) 10 operations. If the array has 1.000 items, the computer performs (approximately) 1.000 operations. If you double the size of the input, the execution time will also double. O(1) Space (or Constant Space) means that the amount of extra memory you use doesn't change, regardless of whether the array has 5 characters or 5 trillion characters.…