aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-09-17 19:04:03 +0800
committercrupest <crupest@outlook.com>2020-09-17 19:04:03 +0800
commit9287f5eb2765e5b8f8a5e2a151b89b211d0259c8 (patch)
tree76f6b7e8cb335578bcc09482aa07e57d3133dbde
parent9b4bb708105aec124f227098e0772fc5855a60f8 (diff)
downloadcrupest-9287f5eb2765e5b8f8a5e2a151b89b211d0259c8.tar.gz
crupest-9287f5eb2765e5b8f8a5e2a151b89b211d0259c8.tar.bz2
crupest-9287f5eb2765e5b8f8a5e2a151b89b211d0259c8.zip
import(solutions): Add problem 1347 .
-rw-r--r--works/solutions/cpp/1347.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/works/solutions/cpp/1347.cpp b/works/solutions/cpp/1347.cpp
new file mode 100644
index 0000000..154a6b5
--- /dev/null
+++ b/works/solutions/cpp/1347.cpp
@@ -0,0 +1,35 @@
+#include <string>
+
+using std::string;
+
+class Solution
+{
+public:
+ int minSteps(string s, string t)
+ {
+ int s_count[26]{0};
+ int t_count[26]{0};
+
+ for (auto c : s)
+ {
+ s_count[c - 'a']++;
+ }
+
+ for (auto c : t)
+ {
+ t_count[c - 'a']++;
+ }
+
+ int result = 0;
+
+ for (int i = 0; i < 26; i++)
+ {
+ int a = s_count[i];
+ int b = t_count[i];
+ if (a > b)
+ result += a - b;
+ }
+
+ return result;
+ }
+}; \ No newline at end of file