two pointers approach O(1) space || JAVA || python || python3
IntuitionApproachiterate every pair of elements and check whether it is same or not if same then perform actions he gave
Approach 1 :
create an empty arr of siz
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
iterate every pair of elements and check whether it is same or not if same then perform actions he gave
Approach 1 :
create an empty arr of size nums.length
iterate in nums if value > 0 then 
update in newarr and increment the index
this approach is faster but space complexity is O(N)
Approach 2 :
use two pointers one points --> 0 and other which is > 0
swap the elements 

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

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

# Code
```java []
class Solution {
    public int[] applyOperations(int[] nums) {
        for (int i=0;i<nums.length-1;i++){
            if (nums[i]==nums[i+1]){
                nums[i]*=2;
                nums[i+1]=0;
            }
        }
        int i;
        int j=0;
        while (j<nums.length){
            if (nums[j]==0){
                i=j+1;
                while (i<nums.length){
                    if (nums[i]>0){
                        nums[j]=nums[i];
                        nums[i]=0;
                        break;
                    }
                    i++;
                }
            }
            j++;
        }
        return nums;

```
```python []
class Solution(object):
    def applyOperations(self, nums):
        for i in range(len(nums)-1):
            if (nums[i]==nums[i+1]):
                nums[i]=nums[i]*2
                nums[i+1]=0
        n=nums.count(0)
        for i in range(n):
            nums.remove(0)
            nums.append(0)

        return nums

        """
        :type nums: List[int]
        :rtype: List[int]
        """
        
```
```python3 []
class Solution:
    def applyOperations(self, nums: List[int]) -> List[int]:
        for i in range(len(nums)-1):
            if (nums[i]==nums[i+1]):
                nums[i]=nums[i]*2
                nums[i+1]=0
        n=nums.count(0)
        for i in range(n):
            nums.remove(0)
            nums.append(0)

        return nums

      




```
['Python', 'Java', 'Python3']