Approach #1: Direct [Accepted]
Intuition and Algorithm
We can do this in place. In each row, the
ith value from the left is equal to the inverse of the
ith value from the right.
(C+1) / 2 (with floor division) to iterate over all indexes
i in the first half of the row, including the center.
Time Complexity: , where
Nis the total number of elements in
Space Complexity: in additional space complexity.
Analysis written by: @awice.