We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4e4888a + 377dbd5 commit 10916e1Copy full SHA for 10916e1
Anagram/anagram.cpp
@@ -0,0 +1,34 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+bool areAnagram(string str1, string str2)
5
+{
6
7
+ int n1 = str1.length();
8
+ int n2 = str2.length();
9
10
+ if (n1 != n2)
11
+ return false;
12
13
+ sort(str1.begin(), str1.end());
14
+ sort(str2.begin(), str2.end());
15
16
+ for (int i = 0; i < n1; i++)
17
+ if (str1[i] != str2[i])
18
19
20
+ return true;
21
+}
22
23
24
+int main()
25
26
+ string str1 = "abc";
27
+ string str2 = "cab";
28
+ if (areAnagram(str1, str2))
29
+ cout << "True";
30
+ else
31
+ cout << "False";
32
33
+ return 0;
34
0 commit comments