Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def createAnagram(s, t)
- cnt1 = Array.new(26)
- cnt2 = Array.new(26)
- x = 0
- while (x < 26)
- cnt1[x] = 0
- cnt2[x] = 0
- x = x + 1
- end
- x = 0
- while (x < s.length)
- cnt1[s[x].ord - 'A'.ord] = cnt1[s[x].ord - 'A'.ord] + 1
- cnt2[t[x].ord - 'A'.ord] = cnt2[t[x].ord - 'A'.ord] + 1
- x = x + 1
- end
- ans = 0
- x = 0
- while (x < 26)
- ans = ans + (cnt1[x] - cnt2[x]).abs
- x = x + 1
- end
- return ans / 2
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement