Given two strings, write a method to decide if one is a permutation of the other.
python
class Solution:
"""
@param: A: a string
@param: B: a string
@return: a boolean
"""
def Permutation(self, A, B):
# write your code here
if A is None and B is not None:
return False
if A is not None and B is None:
return False
if A is None and B is None:
return True
if len(A) != len(B):
return False
arr = [0] * 256
for ele in list(A):
arr[ord(ele)] += 1
for val in list(B):
arr[ord(val)] -= 1
if arr[ord(val)] < 0:
return False
return True