Drive Equation 100% fast || Java
\n\n\nImplementation Of Above Equation\n\nclass Solution {\n    public int[] minOperations(String boxes) {\n        int n =  boxes.length();\n        int suffix
![image](https://assets.leetcode.com/users/images/d3fe940c-663e-4500-aee7-5b5995c51f0e_1638756782.6873157.png)\n\n\n**Implementation Of Above Equation**\n```\nclass Solution {\n    public int[] minOperations(String boxes) {\n        int n =  boxes.length();\n        int suffix[] =  new int[n];\n        int prefix[] =  new int[n];\n        int count1=0;\n        if(boxes.charAt(0)==\'1\') count1++;\n        for(int i=1;i<n;i++ ){\n            prefix[i] =  prefix[i-1]+count1;\n            \n            if(boxes.charAt(i)==\'1\') count1++;\n        }\n        count1=0;\n        if(boxes.charAt(n-1)==\'1\') count1++;\n        for(int i=n-2;i>=0;i--){\n            suffix[i] = suffix[i+1]+count1;\n            if(boxes.charAt(i)==\'1\') count1++;\n        }\n        \n        int ans[] =  new int[n];\n        for(int i=0;i<n;i++){\n            ans[i]=  prefix[i]+suffix[i];\n        }\n        return ans;\n    }\n}\n\n```
['Java']