标签:
Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
判断两字符串含有的元素是否相同。
对字符串进行排序,在判断两字符串是否相等。
1 class Solution { 2 public: 3 bool isAnagram(string s, string t) { 4 sort(s.begin(),s.end()); 5 sort(t.begin(),t.end()); 6 return s==t; 7 } 8 };
标签:
原文地址:http://www.cnblogs.com/19q3/p/5493008.html