力扣:面试题0102
给定两个字符串 s1 和 s2,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。
示例 1:
输入: s1 = “abc”, s2 = “bca”
输出: true
示例 2:
输入: s1 = “abc”, s2 = “bad”
输出: false
说明:
0 <= len(s1) <= 100
0 <= len(s2) <= 100
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/check-permutation-lcci
class Solution(object):
def CheckPermutation(self, s1, s2):
"""
:type s1: str
:type s2: str
:rtype: bool
"""
if len(s1) == len(s2):
a1 = sorted(tuple(s1))
a2 = sorted(tuple(s2))
if a1 == a2:
return True
return False