Posted on

Description

Submission

class Solution {
public:
    vector<int> minOperations(string boxes) {
        int n = boxes.size();
        vector<int> ret(n, 0);

        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                if(boxes[j] == '1') {
                    ret[i] += abs(i - j);
                }
            }
        }

        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *