We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eb8945c commit ab8f2aeCopy full SHA for ab8f2ae
my-submissions/e2460.py
@@ -0,0 +1,16 @@
1
+class Solution:
2
+ def applyOperations(self, nums: List[int]) -> List[int]:
3
+ for i in range(len(nums) - 1) :
4
+ if nums[i] == nums[i + 1] :
5
+ nums[i] *= 2
6
+ nums[i + 1] = 0
7
+
8
+ insert_indx = 0
9
10
+ for i in range(len(nums)) :
11
+ if nums[i] == 0 :
12
+ continue
13
+ nums[insert_indx], nums[i] = nums[i], nums[insert_indx]
14
+ insert_indx += 1
15
16
+ return nums
0 commit comments