-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1.c
64 lines (50 loc) · 1.19 KB
/
1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// The program must accept two string values S1 and S2 as the input.
// The program must find the absolute difference between the number of common characters and the number
// of uncommon characters in the string values and print the value as the output.
// Boundary Condition(s):
// 1 <= Length of S1, Length of S2 <= 10^6
// Input Format:
// The first line contains S1
// The second line contains S2
// Output Format:
// The first line contains the positive integer value denoting the absolute difference
// Example Input/Output 1:
// Input:
// abcdxyza
// bcdxmnomm
// Output:
// 2
#include<stdio.h>
#include<string.h>
int find(int a[])
{
int c=0;
for(int i=0;i<26;i++)
c+=a[i];
return c;
}
int main()
{
char s1[100],s2[100];
scanf("%s%s",s1,s2);
int u,c,total[26]={0},ans[26]={0};
for(int i=0;i<strlen(s1);i++)
{
for(int j=0;j<strlen(s2);j++)
{
total[s1[i]-97]=1;
total[s2[j]-97]=1;
if(s1[i]==s2[j])
{
ans[s1[i]-97]=1;
break;
}
}
}
c=find(ans);
u=find(total)-c;
if((u-c)<0)
printf("%d",-1*(u-c));
else
printf("%d",u-c);
}