Untitled
unknown
python
2 years ago
387 B
6
Indexable
class Solution: def minimumOperations(self, nums: List[int]) -> int: d = deque(nums) res = 0 while len(d) > 1: if d[0] == d[-1]: d.pop() d.popleft() continue res += 1 p,a = (d.popleft,d.appendleft) if d[0]<d[-1] else (d.pop,d.append) a(p()+p()) return res
Editor is loading...