1674. Minimum Moves to Make Array Complementary
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
import bisect
import collections

class Solution:
    def minMoves(self, nums, limit):
        n = len(nums) // 2
        left = nums[:n]
        right = list(reversed(nums[n:]))
        min_vals = sorted(min(x, y) for x, y in zip(left, right))
        max_vals = sorted(max(x, y) for x, y in zip(left, right))
        sum_counts = collections.Counter(x + y for x, y in zip(left, right))

        result = float('inf')
        for total in range(2, 2 * limit + 1):
            current = sum_counts[total]
            left_bound = bisect.bisect_left(max_vals, total - limit)
            right_bound = n - bisect.bisect_left(min_vals, total)
            result = min(result, n - current + left_bound + right_bound)

        return result

```
['Python3']