2186. Minimum Number of Steps to Make Two Strings Anagram II 發表於 2023-02-13 | 分類於 leetcode problemsolution123456789101112class Solution {public: int minSteps(string s, string t) { // beacuse only have lowercase English vector<int> ret(26,0); for(char c:s) ret[c-'a']++; for(char c:t) ret[c-'a']--; int count = 0; for(int r:ret) count+=(abs(r)); return count; }}; analysis time complexity O(n) space complexity O(1)