| 1 | #include <bits/stdc++.h> |
| 2 | using namespace std; |
| 3 | bool areAnagram(string str1, string str2) |
| 4 | { |
| 5 | |
| 6 | int n1 = str1.length(); |
| 7 | int n2 = str2.length(); |
| 8 | |
| 9 | if (n1 != n2) |
| 10 | return false; |
| 11 | |
| 12 | sort(str1.begin(), str1.end()); |
| 13 | sort(str2.begin(), str2.end()); |
| 14 | |
| 15 | for (int i = 0; i < n1; i++) |
| 16 | if (str1[i] != str2[i]) |
| 17 | return false; |
| 18 | return true; |
| 19 | } |
| 20 | |
| 21 | int main() |
| 22 | { |