Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency For example, bacdc and dcbac are anagrams, but bacdc and dcbad are not.
  2.  
  3. Alice decides on an encryption scheme involving two large strings where encryption is dependent on the minimum number of character deletions required to make the two strings anagrams. Can you help her find this number?
  4.  
  5. Given two strings, and , that may or may not be of the same length, determine the minimum number of character deletions required to make and anagrams. Any characters can be deleted from either of the strings.
  6.  
  7. #### Input Format
  8.  
  9. The first line contains a single string, *a*.
  10. The second line contains a single string, *b* .
  11.  
  12. #### Constraints
  13. * 1 ≤ |a|, |b| ≤ 10<sup>4</sup>
  14. * It is guaranteed that and consist of lowercase English alphabetic letters (i.e., through ).
  15.  
  16. #### Output Format
  17.  
  18. Print a single integer denoting the number of characters you must delete to make the two strings anagrams of each other.
  19.  
  20. #### Sample Input
  21.  
  22. abc
  23. cde
  24.  
  25. #### Sample Output
  26.  
  27. 4
  28.  
  29. #### Explanation
  30.  
  31. We delete the following characters from our two strings to turn them into anagrams of each other:
  32. 1. Remove d and e from cde to get c.
  33. 2. Remove a and b from abc to get c.
  34. We must delete characters to make both strings anagrams, so we print on a new line.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement