Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.
Return the minimum number of steps to make t an anagram of s.
An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.
 
Example 1:
Input: s = "bab", t = "aba"
Output: 1
Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.

Example 2:
Input: s = "leetcode", t = "practice"
Output: 5
Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.

Example 3:
Input: s = "anagram", t = "mangaar"
Output: 0
Explanation: "anagram" and "mangaar" are anagrams. 

Example 4:
Input: s = "xxyyzz", t = "xxyyzz"
Output: 0

Example 5:
Input: s = "friend", t = "family"
Output: 4

 
Constraints:

1 <= s.length <= 50000
s.length == t.length
s and t contain lower-case English letters only.

Source: leetcode | Difficulty: MEDIUM
Tags: String algorithms

Data structures

Mathematics

Starter code: class Solution:
    def minSteps(self, s: str, t: str) -> int:
        

Solutions:
class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_count = [s.count(chr(i)) for i in range(97, 123)]
		t_count = [t.count(chr(i)) for i in range(97, 123)]
		diff = [t_count[i] - s_count[i] for i in range(26) if t_count[i] - s_count[i] > 0]
		sum = 0
		for i in range(len(diff)):
			sum = sum + diff[i]
		return sum


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		abc = 'abcdefghijklmnopqrstuvwxyz'
		return int(sum((abs(t.count(l) - s.count(l)) for l in abc)) / 2)


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		(c1, c2) = map(Counter, (s, t))
		return len(list((c1 - c2).elements()))


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		freq_s = {}
		freq_t = {}
		for keys in s:
			freq_s[keys] = freq_s.get(keys, 0) + 1
		for t_keys in t:
			freq_t[t_keys] = freq_t.get(t_keys, 0) + 1
		changes = 0
		for (key, val) in freq_s.items():
			val = freq_s[key]
			val_t = freq_t.get(key, 0)
			if val > val_t:
				changes += val - val_t
		return changes


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_map = {}
		change = 0
		for ch in s:
			if ch not in s_map:
				s_map[ch] = 1
			else:
				s_map[ch] += 1
		for i in range(0, len(t)):
			if t[i] in s_map and s_map[t[i]] > 0:
				s_map[t[i]] -= 1
			else:
				change += 1
		return change


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		arr1 = defaultdict()
		arr2 = defaultdict()
		count = 0
		for i in range(len(s)):
			arr1[s[i]] = arr1.get(s[i], 0) + 1
			arr2[t[i]] = arr2.get(t[i], 0) + 1
		for i in range(len(t)):
			if t[i] not in arr1:
				count = count + arr2[t[i]]
				arr2[t[i]] = 0
				continue
			if arr2[t[i]] > arr1[t[i]]:
				count = count + arr2[t[i]] - arr1[t[i]]
				arr2[t[i]] = arr1[t[i]]
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = collections.Counter(s)
		res = 0
		for c in t:
			if count[c] > 0:
				count[c] -= 1
			else:
				res += 1
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s = list(s)
		t = list(t)
		dic = dict()
		for i in s:
			if i in dic:
				dic[i] = dic[i] + 1
			else:
				dic[i] = 1
		print(dic)
		for j in t:
			if j in dic:
				dic[j] = dic[j] - 1
		print(dic)
		sum = 0
		for i in list(dic.values()):
			if i > 0:
				sum += i
		return sum


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		minSteps = 0
		dict = {}
		for ch in s:
			if dict.get(ch):
				dict[ch] += 1
			else:
				dict[ch] = 1
		for c in t:
			num = dict.get(c)
			if num:
				dict[c] -= 1
				if num < 0:
					minSteps += 1
			else:
				minSteps += 1
		return minSteps


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if len(s) != len(t):
			return 0
		hash_map = dict()
		count = 0
		for char in s:
			hash_map[char] = hash_map.get(char, 0) + 1
		for char in t:
			if hash_map.get(char, 0) > 0:
				hash_map[char] -= 1
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		hash_ = dict()
		for i in range(len(s)):
			hash_.setdefault(t[i], 0)
			hash_.setdefault(s[i], 0)
			hash_[t[i]] -= 1
			hash_[s[i]] += 1
		sum_ = 0
		for v in hash_.values():
			if v > 0:
				sum_ += v
		return sum_


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		return sum((Counter(t) - Counter(s)).values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		cs = collections.Counter(s)
		ct = collections.Counter(t)
		for x in s:
			if x in ct and ct[x] > 0:
				ct[x] -= 1
				cs[x] -= 1
		return sum(cs.values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		maps = {}
		mapt = {}
		for i in range(0, len(s)):
			if s[i] not in maps:
				maps[s[i]] = 1
			elif s[i] in maps:
				maps[s[i]] = maps[s[i]] + 1
			if t[i] not in mapt:
				mapt[t[i]] = 1
			elif t[i] in mapt:
				mapt[t[i]] = mapt[t[i]] + 1
		count = 0
		l = set()
		for j in range(0, len(s)):
			if s[j] not in l and s[j] not in mapt:
				l.add(s[j])
				count = count + maps[s[j]]
			elif s[j] not in l and maps[s[j]] > mapt[s[j]]:
				l.add(s[j])
				count = count + (maps[s[j]] - mapt[s[j]])
		return count


import collections

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		c1 = collections.Counter(s)
		c2 = collections.Counter(t)
		c = 0
		for i in s:
			if c2[i] > 0:
				c1[i] -= 1
				c2[i] -= 1
		l = list(c1.values())
		for i in l:
			if i > 0:
				c += i
		return c


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if len(s) != len(t):
			return -1
		obj = dict()
		missing = dict()
		total = 0
		for i in range(len(s)):
			if obj.get(s[i]) == None:
				obj[s[i]] = 1
			else:
				obj[s[i]] = obj[s[i]] + 1
		for j in range(len(t)):
			if obj.get(t[j]) == None:
				if missing.get(t[j]) == None:
					missing[t[j]] = 1
				else:
					missing[t[j]] = missing[t[j]] + 1
			elif obj.get(t[j]) == 1:
				del obj[t[j]]
			else:
				obj[t[j]] = obj[t[j]] - 1
		for key in missing.keys():
			total = total + missing.get(key)
		return total


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		dic1 = Counter(s)
		dic2 = Counter(t)
		k = 0
		length = s.__len__()
		while k < length:
			c = t[k]
			if dic1[c] > 0:
				dic1[c] -= 1
				dic2[c] -= 1
			k += 1
		return sum(dic2.values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_counter = Counter(s)
		t_counter = Counter(t)
		changes = 0
		for key in list(s_counter.keys()):
			changes += abs(s_counter[key] - t_counter[key])
		for key in list(t_counter.keys()):
			changes += 0 if key in s_counter else t_counter[key]
		return changes // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_dict = {}
		t_dict = {}
		res = 0
		for i in range(len(s)):
			if s[i] in s_dict:
				s_dict[s[i]] = s_dict[s[i]] + 1
			else:
				s_dict[s[i]] = 1
		for j in range(len(t)):
			if t[j] in t_dict:
				t_dict[t[j]] = t_dict[t[j]] + 1
			else:
				t_dict[t[j]] = 1
		print((s_dict, t_dict))
		for i in range(len(s)):
			if s[i] in t_dict and t_dict[s[i]] > 0:
				s_dict[s[i]] -= 1
				t_dict[s[i]] -= 1
		for (key, value) in list(s_dict.items()):
			if value > 0:
				res += value
		print((s_dict, t_dict))
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		res = 0
		s = list(s)
		t = list(t)
		d1 = dict()
		d2 = dict()
		for i in s:
			if i in d1.keys():
				d1[i] += 1
			else:
				d1[i] = 1
		for i in t:
			if i in d2.keys():
				d2[i] += 1
			else:
				d2[i] = 1
		res = 0
		for i in d1.keys():
			if i in d2.keys() and d2[i] < d1[i]:
				res += d1[i] - d2[i]
			elif i not in d2.keys():
				res += d1[i]
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = collections.Counter(s)
		req = 0
		for i in t:
			if i not in count:
				req += 1
			else:
				count[i] -= 1
				if count[i] == 0:
					del count[i]
		if count:
			return req
		else:
			return 0


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		ct = {}
		cs = {}
		for i in range(len(s)):
			ct.update({t[i]: ct.get(t[i], 0) + 1})
			cs.update({s[i]: cs.get(s[i], 0) + 1})
		c = 0
		for (k, v) in cs.items():
			r = v - ct.get(k, 0)
			c += r if r > 0 else 0
		return c


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_list = Counter(s)
		count = 0
		for i in range(len(t)):
			if t[i] in s_list and s_list[t[i]] > 0:
				s_list[t[i]] -= 1
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		char = {}
		c = 0
		for ch in t:
			if ch not in char.keys():
				char[ch] = 1
			else:
				char[ch] += 1
		for ch in s:
			if ch in char.keys() and char[ch] != 0:
				char[ch] -= 1
			else:
				c += 1
		return c


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		c = Counter(s)
		for char in t:
			if char in c:
				c[char] = max(0, c[char] - 1)
		return sum(c.values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		(cnt1, cnt2) = list(map(collections.Counter, (s, t)))
		return sum((cnt1 - cnt2).values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		cnt = Counter(s)
		for x in t:
			if x in cnt.keys() and cnt[x] > 0:
				cnt[x] -= 1
		ans = 0
		for x in cnt.values():
			ans += abs(x)
		return ans


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if len(s) != len(t):
			return -1
		s_count = collections.Counter(s)
		for c in t:
			if c in s_count:
				s_count[c] -= 1
			if s_count[c] == 0:
				del s_count[c]
		total = 0
		for val in list(s_count.values()):
			total += val
		return total


class Solution:

	def minSteps(self, a: str, b: str) -> int:
		count = 0
		a = sorted(a)
		b = sorted(b)
		dic1 = Counter(a)
		dic2 = Counter(b)
		for i in b:
			if i in dic1:
				if dic1[i]:
					dic1[i] -= 1
				else:
					count += 1
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = 0
		a = s
		b = t
		if len(s) == 0:
			return len(t)
		if len(t) == 0:
			return len(s)
		for curr in a:
			if curr in b:
				b = b.replace(curr, '', 1)
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = 0
		for i in s:
			if i in t:
				t = t.replace(i, '', 1)
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		src = Counter(s)
		des = Counter(t)
		src.subtract(des)
		freq = list(src.values())
		ans = 0
		freq = sorted(freq)
		freq = list([a for a in freq if a != 0])
		while len(freq) > 1:
			actions = min(abs(freq[0]), freq[-1])
			ans += actions
			freq[0] = actions + freq[0]
			freq[-1] = freq[-1] - actions
			freq = list([a for a in freq if a != 0])
		if len(freq) == 1:
			ans += freq[0]
		return ans


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		for i in range(0, len(t)):
			if t[i] in s:
				s = s.replace(t[i], '', 1)
		return len(s)


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		(c1, c2) = map(Counter, (s, t))
		return sum((1 for _ in (c1 - c2).elements()))


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		cs = collections.Counter(s)
		ct = collections.Counter(t)
		diff = 0
		for i in ct:
			if i in cs:
				if ct[i] > cs[i]:
					diff += ct[i] - cs[i]
			else:
				diff += ct[i]
		return diff


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		tt = Counter(t)
		ss = Counter(s)
		cnt = 0
		all_c = set(s + t)
		for k in all_c:
			if tt[k] < ss[k]:
				cnt += ss[k] - tt[k]
		return cnt


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		(one, two) = (Counter(s), Counter(t))
		return sum({k: abs(one[k] - two[k]) for k in one | two}.values()) // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		result = len(s)
		for i in set(s):
			n_s = s.count(i)
			n_t = t.count(i)
			result = result - min(n_s, n_t)
		return result


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		countS = Counter(s)
		countT = Counter(t)
		index = 0
		res = 0
		if countS == countT:
			return 0
		for (k, v) in countS.items():
			if v > countT[k]:
				res += v - countT[k]
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d1 = collections.Counter(s)
		d2 = collections.Counter(t)
		return sum((d1 - d2).values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		ds = collections.Counter(list(s))
		dt = collections.Counter(list(t))
		ans = 0
		set_ = set(s + t)
		for i in set_:
			ans += abs(dt[i] - ds[i])
		return ans // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		(s, t) = map(Counter, [s, t])
		return sum((max(s[c] - t[c], 0) for c in s))


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if s == t:
			return 0
		s_count = Counter(s)
		t_count = Counter(t)
		c = 0
		for (i, j) in s_count.items():
			if i in t_count:
				if t_count[i] < j:
					c += j - t_count[i]
			else:
				c += j
		return c


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		sc = Counter(s)
		tc = Counter(t)
		c = 0
		for i in tc:
			c += tc[i]
		for i in tc:
			if i in sc:
				if tc[i] <= sc[i]:
					c -= tc[i]
				elif tc[i] > sc[i]:
					c -= sc[i]
		return c


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		sdict = collections.defaultdict(int)
		for c in s:
			sdict[c] += 1
		for c in t:
			sdict[c] -= 1
		res = 0
		for c in sdict.keys():
			if sdict[c] < 0:
				res += abs(sdict[c])
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if len(s) == len(t) <= 50000 and s.islower() and t.islower():
			if collections.Counter(s) == collections.Counter(t):
				return 0
			diff = collections.Counter(s) - collections.Counter(t)
			return sum(diff.values())
		else:
			return 0


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		sCounts = collections.defaultdict(int)
		tCounts = collections.defaultdict(int)
		for c in s:
			sCounts[c] += 1
		for c in t:
			tCounts[c] += 1
		change = 0
		for k in tCounts:
			if k not in sCounts:
				change += tCounts[k]
			elif k in sCounts and sCounts[k] < tCounts[k]:
				change += tCounts[k] - sCounts[k]
		return change


class Solution:
	from collections import defaultdict

	def minSteps(self, s: str, t: str) -> int:
		counts = defaultdict(int)
		for c in s:
			counts[c] += 1
		for c in t:
			counts[c] -= 1
		return sum((abs(counts[d]) for d in counts)) // 2


from collections import defaultdict

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		h = defaultdict(int)
		k = defaultdict(int)
		for i in s:
			h[i] += 1
		for j in t:
			k[j] += 1
		ans = 0
		for i in h:
			ans += h[i] - k[i] if h[i] - k[i] > 0 else 0
		return ans


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		(counterS, counterT) = (Counter(s), Counter(t))
		res = 0
		for i in counterS:
			res += max(0, counterS[i] - counterT[i])
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		(ds, dt) = (defaultdict(int), defaultdict(int))
		for c in list(s):
			ds[c] += 1
		for c in list(t):
			dt[c] += 1
		res = 0
		for c in dt:
			res += max(0, dt[c] - ds[c])
		return res


from collections import defaultdict

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		freq = defaultdict(int)
		for char in s:
			freq[char] += 1
		for char in t:
			if freq[char] > 0:
				freq[char] -= 1
		return sum(freq.values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count1 = {}
		count2 = {}
		for ch in s:
			if ch not in count1:
				count1[ch] = 0
			count1[ch] += 1
		for ch in t:
			if ch not in count2:
				count2[ch] = 0
			count2[ch] += 1
		count = 0
		for ch in count2:
			if ch in count1:
				if count1[ch] == count2[ch]:
					continue
				elif count2[ch] > count1[ch]:
					diff = count2[ch] - count1[ch]
					count += diff
					continue
				else:
					pass
			else:
				count += count2[ch]
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		a = {}
		b = {}
		for i in s:
			if i in a:
				a[i] += 1
			else:
				a[i] = 1
		for j in t:
			if j in b:
				b[j] += 1
			else:
				b[j] = 1
		v = 0
		for i in a:
			if i in b and a[i] > b[i]:
				v += a[i] - b[i]
			elif i not in b:
				v += a[i]
			else:
				v += 0
		return v


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_set = set(s)
		steps = 0
		for char in s_set:
			s_charfreq = s.count(char)
			t_charfreq = t.count(char)
			if s_charfreq > t_charfreq:
				steps += s_charfreq - t_charfreq
		return steps


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d1 = {}
		for i in s:
			d1[i] = d1.get(i, 0) + 1
		d2 = {}
		for i in t:
			d2[i] = d2.get(i, 0) + 1
		c = 0
		for i in d1:
			k = d1[i] - d2.get(i, 0)
			if k > 0:
				c += abs(k)
		return c


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		help_dict = defaultdict(int)
		res = 0
		for char in s:
			help_dict[char] += 1
		for char in t:
			if help_dict[char] > 0:
				help_dict[char] -= 1
			else:
				res += 1
		return res


from collections import defaultdict

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		mapper1 = defaultdict(int)
		mapper2 = defaultdict(int)
		for i in range(len(s)):
			mapper1[s[i]] += 1
			mapper2[t[i]] += 1
		count = 0
		for (char, val) in mapper1.items():
			diff = val - mapper2[char]
			if diff > 0:
				count += diff
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		steps = 0
		myDict = {}
		for c in s:
			if c in myDict:
				myDict[c] += 1
			else:
				myDict[c] = 1
		for c in t:
			if c in myDict:
				myDict[c] -= 1
				if myDict[c] == 0:
					del myDict[c]
			else:
				steps += 1
		return steps


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		sFreq = dict()
		for char in s:
			try:
				sFreq[char] += 1
			except:
				sFreq[char] = 1
		ans = 0
		for char in t:
			if char in sFreq and sFreq[char] > 0:
				sFreq[char] -= 1
			else:
				ans += 1
		return ans


import collections

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		counter = collections.Counter(s)
		for c in t:
			counter[c] -= 1
		return sum([abs(x) for x in list(counter.values())]) // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = 0
		for ch2 in set(s):
			n = s.count(ch2)
			m = t.count(ch2)
			if ch2 in t:
				if m < n:
					count += n - m
			else:
				count += n
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import defaultdict
		s_f = defaultdict(int)
		t_f = defaultdict(int)
		c = 0
		for x in s:
			s_f[x] += 1
		for y in t:
			t_f[y] += 1
		for z in s_f:
			s_i = s_f[z] - t_f[z]
			if s_i > 0:
				c += s_i
		return c


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_count = {}
		t_count = {}
		for i in range(len(s)):
			s_char = s[i]
			t_char = t[i]
			if s_char in s_count:
				s_count[s_char] += 1
			else:
				s_count[s_char] = 1
			if t_char in t_count:
				t_count[t_char] += 1
			else:
				t_count[t_char] = 1
		for c in t_count:
			if c in s_count:
				s_count[c] = abs(s_count[c] - t_count[c])
			else:
				s_count[c] = t_count[c]
		return sum(s_count.values()) // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		counter = {}
		count = 0
		for c in s:
			counter[c] = counter.get(c, 0) + 1
		for c in t:
			if c in counter and counter[c] > 0:
				counter[c] -= 1
			else:
				count += 1
		return count


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d = Counter(s)
		res = 0
		for char in t:
			if d[char] > 0:
				d[char] -= 1
			else:
				res += 1
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		from collections import Counter
		counts = Counter(s)
		res = 0
		for c in t:
			if counts[c] > 0:
				counts[c] -= 1
			else:
				res += 1
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		sdict = {}
		for i in s:
			if sdict.get(i) == None:
				sdict[i] = 1
			else:
				sdict[i] += 1
		for j in t:
			if sdict.get(j):
				sdict[j] -= 1
		return sum(sdict.values())


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if s is None or t is None:
			return -1
		hashmap = dict()
		count = 0
		for char in s:
			if char in hashmap:
				hashmap[char] = 1 + hashmap[char]
			else:
				hashmap[char] = 1
		for char in t:
			if char in hashmap:
				if hashmap[char] is not 0:
					hashmap[char] = hashmap[char] - 1
		for key in hashmap:
			count += hashmap[key]
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if s == t:
			return 0
		s_d = collections.Counter(s)
		for c in t:
			if c in s_d and s_d[c] > 0:
				s_d[c] -= 1
		return sum(s_d.values())


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count = 0
		for i in set(s):
			if s.count(i) > t.count(i):
				count += s.count(i) - t.count(i)
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		ms = {}
		for c in s:
			old = ms.get(c, 0)
			ms[c] = old + 1
		count = 0
		for c in t:
			old = ms.get(c, 0)
			if old == 0:
				count += 1
			else:
				ms[c] -= 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_count = dict()
		t_count = dict()
		for i in range(len(s)):
			s_count[s[i]] = s_count.get(s[i], 0) + 1
		for i in range(len(t)):
			t_count[t[i]] = t_count.get(t[i], 0) + 1
		sim_count = 0
		for key in list(s_count.keys()):
			if t_count.get(key, 0):
				if s_count[key] >= t_count[key]:
					sim_count += t_count[key]
				else:
					sim_count += s_count[key]
		return len(s) - sim_count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d = {}
		count = 0
		for i in range(len(s)):
			if s[i] not in d:
				d[s[i]] = 1
			else:
				d[s[i]] += 1
		for i in range(len(t)):
			if t[i] in d and d[t[i]] > 0:
				d[t[i]] -= 1
			else:
				count += 1
		return count


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		all_set = set(list(s)) | set(list(t))
		res = 0
		for x in all_set:
			res = res + abs(s.count(x) - t.count(x))
		res = res // 2
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		s_dict = {}
		t_dict = {}
		diff = 0
		for i in s:
			if i in s_dict:
				s_dict[i] += 1
			else:
				s_dict[i] = 1
		for i in t:
			if i in t_dict:
				t_dict[i] += 1
			else:
				t_dict[i] = 1
		for i in s:
			if i in t_dict and t_dict[i] > 0:
				t_dict[i] -= 1
		for i in t_dict:
			diff += t_dict[i]
		return diff


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		D_s = {}
		D_t = {}
		for v in t:
			D_t[v] = 0
		for v in t:
			D_t[v] += 1
		for v in s:
			D_s[v] = 0
		for v in s:
			D_s[v] += 1
		S = 0
		U = set()
		for v in t:
			if v not in D_s:
				S += 1
			else:
				U.add(v)
		for u in U:
			S += max(D_t[u] - D_s[u], 0)
		return S


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		min_steps = 0
		count = collections.Counter(s)
		for char in t:
			if char not in count:
				min_steps += 1
			else:
				count[char] -= 1
				if count[char] == 0:
					del count[char]
		return min_steps


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		changes_to_char = {}
		for i in range(len(s)):
			s_char_changes = changes_to_char.get(s[i], 0) + 1
			changes_to_char[s[i]] = s_char_changes
			t_char_changes = changes_to_char.get(t[i], 0) - 1
			changes_to_char[t[i]] = t_char_changes
		total_dist = 0
		for (char, char_dist) in changes_to_char.items():
			if char_dist > 0:
				total_dist += char_dist
		return total_dist


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count_t = collections.Counter(t)
		for i in range(len(s)):
			if s[i] in count_t:
				count_t[s[i]] -= 1
				if count_t[s[i]] == 0:
					del count_t[s[i]]
		ans = 0
		for (key, value) in count_t.items():
			ans += value
		return ans


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		countChars = dict()
		for i in s:
			if i in countChars:
				countChars[i][0] += 1
			else:
				countChars[i] = [1, 0]
		ctr = 0
		for j in t:
			if j in countChars:
				countChars[j][1] += 1
			else:
				countChars[j] = [0, 1]
		for i in countChars:
			if countChars[i][0] > countChars[i][1]:
				ctr += countChars[i][0] - countChars[i][1]
		return ctr


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		count_s = Counter(s)
		count = 0
		for char in t:
			if count_s[char] > 0:
				count_s[char] -= 1
			else:
				count += 1
		return count


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d1 = Counter()
		d2 = Counter()
		n = len(s)
		cnt = 0
		for (i, a) in enumerate(s):
			d1[a] = d1[a] + 1
		print(d1)
		for (j, b) in enumerate(t):
			d2[b] = d2[b] + 1
		print(d2)
		for (k1, v1) in list(d1.items()):
			if k1 in d2:
				v2 = d2[k1]
				cnt = cnt + min(v1, v2)
		return n - cnt


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		x = dict(Counter(list(s)))
		count = 0
		for i in range(len(t)):
			v = x.get(t[i], None)
			if v != None and v > 0:
				x[t[i]] -= 1
			else:
				count += 1
		print(count)
		return count


from collections import Counter

class Solution:

	def minSteps(self, s: str, t: str) -> int:
		d1 = Counter(s)
		d2 = Counter(t)
		res = 0
		if d1 == d2:
			return 0
		for i in s:
			if i in d2:
				d1[i] -= 1
				d2[i] -= 1
				if d1[i] == 0:
					del d1[i]
				if d2[i] == 0:
					del d2[i]
		for (key, val) in list(d2.items()):
			res += val
		return res


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		dict1 = {}
		dict2 = {}
		for i in s:
			if i not in dict1:
				dict1[i] = 1
			else:
				dict1[i] += 1
		for i in t:
			if i not in dict2:
				dict2[i] = 1
			else:
				dict2[i] += 1
		c_chars = 0
		d_chars = 0
		for i in dict1:
			if i in dict2:
				if dict2[i] > dict1[i]:
					c = dict2[i] - dict1[i]
				else:
					c = dict1[i] - dict2[i]
				c_chars += c
			else:
				d_chars += dict1[i]
		for i in dict2:
			if i not in dict1:
				d_chars += dict2[i]
		return (c_chars + d_chars) // 2


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		if len(s) != len(t):
			return -1
		elif sorted(s) == sorted(t):
			return 0
		I = set(s).intersection(t)
		freq_s = {}
		for c in s:
			if c in I:
				freq_s[c] = freq_s.get(c, 0) + 1
		freq_t = {}
		for c in t:
			if c in I:
				freq_t[c] = freq_t.get(c, 0) + 1
		I_sum = 0
		for c in list(freq_t.keys()):
			freq_t[c] = min(freq_s[c], freq_t[c])
			I_sum += freq_t[c]
		return len(t) - I_sum


class Solution:

	def minSteps(self, s: str, t: str) -> int:
		dic = collections.Counter(s)
		for letter in t:
			if letter in dic and dic[letter] > 0:
				dic[letter] -= 1
		return sum(dic.values())