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 086ea11 commit 7dec50dCopy full SHA for 7dec50d
1676C - Most Similar Words.cpp
@@ -0,0 +1,42 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+
4
+// Code Written By: Vikash Patel
5
6
+// Codeforces Profile: https://codeforces.com/profile/vikashpatel
7
8
+int strDiff(string x, string y)
9
+{
10
+ int sum = 0;
11
+ for (int i = 0; i < x.size (); i++)
12
+ {
13
+ sum += abs (x[i] - y[i]);
14
+ }
15
+ return sum;
16
+}
17
18
+int main()
19
20
+ int t;
21
+ cin >> t;
22
+ while (t--)
23
24
+ int n, m;
25
+ cin >> n >> m;
26
+ string s[n];
27
+ for (int i = 0; i < n; i++)
28
29
+ cin >> s[i];
30
31
+ int mini = INT_MAX;
32
33
34
+ for (int j = 0; j < n; j++)
35
36
+ if (i != j)
37
+ mini = min (mini, strDiff (s[i], s[j]));
38
39
40
+ cout << mini << endl;
41
42
0 commit comments