One Pass [C++/Java/Python3]
Just do Operation and Swapping of non-zeroes at front of array simultaneously.\n# C++\n    vector applyOperations(vector& A) {\n        for (int i = 0, j = 0; i
Just do `Operation` and `Swapping of non-zeroes at front` of array simultaneously.\n# C++\n    vector<int> applyOperations(vector<int>& A) {\n        for (int i = 0, j = 0; i < size(A); ++i){\n            if (i + 1 < size(A) and A[i] == A[i + 1]){\n                A[i] *= 2;\n                A[i + 1] = 0;\n            }\n            if (A[i]) swap(A[j++], A[i]);\n        }   \n        return A;\n    }\n# Java\n    void swap(int[] A, int i, int j){\n        int temp = A[i];\n        A[i] = A[j];\n        A[j] = temp;\n    }\n    \n    public int[] applyOperations(int[] A) {\n        for (int i = 0, j = 0; i < A.length; ++i){\n            if (i + 1 < A.length && A[i] == A[i + 1]){\n                A[i] *= 2;\n                A[i + 1] = 0;\n            }\n            if (A[i] != 0){\n                swap(A,i,j);\n                j++;\n            }\n        }   \n        return A;\n    }\n# Python3\n    def applyOperations(self, A: List[int]) -> List[int]:\n        j = 0\n        for i in range(len(A)):\n            if i + 1 < len(A) and A[i] == A[i + 1]:\n                A[i] *= 2\n                A[i + 1] = 0 \n            if A[i]:\n                A[j], A[i] = A[i], A[j]\n                j += 1 \n        return A
['C']