LeetCode:Valid Anagram

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     }
9 };

 

posted @ 2015-08-04 10:38  尾巴草  阅读(94)  评论(0编辑  收藏  举报