We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dec706f commit 2bf2723Copy full SHA for 2bf2723
Placement/String/Anagram.cpp
@@ -0,0 +1,34 @@
1
+//Checking weather one string is anagram of other.(Permutation of one another)
2
+#include<bits/stdc++.h>
3
+using namespace std;
4
+int main()
5
+{
6
+ string s1,s2;
7
+ int cnt1[26]={0};
8
+ int cnt2[26]={0};
9
+ cin>>s1>>s2;
10
+ for(int i=0;s1[i];i++)
11
+ {
12
+ cnt1[s1[i]-'a']++;
13
+ }
14
+ for(int i=0;s2[i];i++)
15
16
+ cnt2[s2[i]-'a']++;
17
18
+ int f=0;
19
+ for(int i=0;i<26;i++)
20
21
+ if(cnt1[i]!=cnt2[i])
22
23
+ f=1;
24
+ break;
25
26
27
+ if(f==1)
28
29
+ cout<<"Not Anagram\n";
30
31
+ else
32
+ cout<<"Anagram\n";
33
+ return 0;
34
+}
0 commit comments