Posted on

Description

Submission

class Solution {
public:
    int minSteps(string s, string t) {
        vector<int> cnt1(26);
        vector<int> cnt2(26);
        
        for(char c: s) {
            cnt1[c-'a']++;
        }
        
        for(char c: t) {
            cnt2[c-'a']++;
        }
        
        int ret = 0;
        for(int i = 0; i < 26; ++i) {
            // cnt1 as standard
            if(cnt1[i] < cnt2[i]) ret += cnt2[i] - cnt1[i];
        }
        return ret;
    }
};

Leave a Reply

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