# 2422. Merge Operations to Turn Array Into a Palindrome ###### tags: `Leetcode` `Medium` `Two Pointers` Link: https://leetcode.com/problems/merge-operations-to-turn-array-into-a-palindrome/description/ ## 思路 如果左指针和右指针的value一样 可以直接skip 不需要做合并 如果不一样 哪边小 哪边指针移动 执行merge操作 ## Code ```python= class Solution: def minimumOperations(self, nums: List[int]) -> int: left, right = nums[0], nums[-1] l, r = 0, len(nums)-1 count = 0 while l<r: if left==right: l += 1 r -= 1 left, right = nums[l], nums[r] else: if left<right: l += 1 left += nums[l] else: r -= 1 right += nums[r] count += 1 return count ```