### Question

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.

Note:
You may assume the string contains only lowercase alphabets.

### Code

#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(), s.end());
sort(t.begin(), t.end());
if (s == t) return true;
else return false;
}
};

int main() {
Solution so;
string s = "rat";
string t = "car";
cout << so.isAnagram(s, t) << endl;
system("pause");
return  0;
}

### 点评

#### LeetCode:242 Valid Anagram Java

2015-08-05 21:07:08

#### LeetCode（242）Valid Anagram

2015-11-17 13:33:46

#### leetcode 242: Valid Anagram

2015-08-02 15:57:10

#### [LeetCode] Valid Anagram - 字符串排序比较系列

2015-09-14 07:01:49

#### LeetCode 242. Valid Anagram 题解（C++）

2016-10-19 13:43:33

#### 242. Valid Anagram [easy] (Python)

2016-05-14 15:07:05

#### leetcode_Valid Anagram

2015-08-06 21:28:03

#### Leetcode：242. Valid Anagram（JAVA）

2016-03-01 11:55:19

#### 【LeetCode-242】Valid Anagram(C++)

2016-01-17 21:54:40

#### 【LEETCODE】242-Valid Anagram [Python]

2016-01-29 11:04:15

## 不良信息举报

【leetcode】Valid Anagram