Initial Solution
Time complexity and Space Complexity
Time Complexity: O(n) - In the worst case, we traverse the array once using two pointers that move towards each other.
Space Complexity: O(1) - We only use a constant amount of extra space for the two pointers (i and q).