Problem statement

https://binarysearch.com/problems/Minimum-String/

Solution

Calculate how many elements we have in common using counters, then subtract this number form length.

Complexity

It is O(n) for time and O(26) for space.

Code

class Solution:
    def solve(self, s, t):
        return len(s) - sum(x for x in (Counter(s) & Counter(t)).values())