[Python] Share my bisect solution
We first get the maximum possible summation of pairs,\npython\ncsmax = min(max(nums[i], nums[n-i-1]) for i in range(n//2)) + limit\n\n\nThen we check all existe
We first get the maximum possible summation of pairs,\n```python\ncsmax = min(max(nums[i], nums[n-i-1]) for i in range(n//2)) + limit\n```\n\nThen we check all existed pairwise summations `key` no greater than this number. The number of moves needed for a target `key` is\n```\nn // 2 - pairs_already_summed_to_key + pairs_with_both_number_greater_than_`key` (need modify both numbers)\n```\n\nFor both_number_greater_than_`key`, we can maintain an array of "smaller number in the pair" and use a bisection to find the number of such pairs\n\n```python\ncsmin = [min(nums[i], nums[n-i-1]) for i in range(n//2)]\ncsmin.sort()\ntwo_k = n // 2 - bisect.bisect_left(csmin, key)\n```\n\nOverall,\n\n```python\nfrom collections import Counter\nimport bisect\n\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        n = len(nums)\n\n        c = Counter([nums[i] + nums[n - i - 1] for i in range(n//2)])\n\n        if len(c) == 1:\n            return 0\n        \n        csmax = min(max(nums[i], nums[n-i-1]) for i in range(n//2)) + limit\n        \n        csmin = [min(nums[i], nums[n-i-1]) for i in range(n//2)]\n        csmin.sort()\n\n        best = n\n        for key in c.keys():\n            if key > csmax:\n                continue\n\n            # two_k = sum([nums[i] >= k and nums[n-i-1] >= k for i in range(n//2)])\n            two_k = n // 2 - bisect.bisect_left(csmin, key)\n\n            res = n // 2 - c[key] + two_k\n\n            best = min(best, res)\n        \n        return best\n```
[]