Minimum Number of Steps to Make Two Strings Anagram LeetCode solution in Java
1// find the frequency of every letter and check diffrence between the frequency of each letter then2// divide it by 2 to calculate the minimum number of letter to be changed.3class Solution {4public int minSteps(String s, String t) {5int sf[] = new int[26];6int tf[] = new int[26];7int diff = 0;8for (char c : s.toCharArray()) {9sf[c - 'a']++;10}11for (char c : t.toCharArray()) {12tf[c - 'a']++;13}14for (int i = 0; i < 26; i++) {15diff += (int) Math.abs(sf[i] - tf[i]);16}17return diff / 2;18}19}