aboutsummaryrefslogtreecommitdiffstats
path: root/13
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x1347/main.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/1347/main.py b/1347/main.py
new file mode 100755
index 0000000..ba3f0a5
--- /dev/null
+++ b/1347/main.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+
+class Solution:
+ def minSteps(self, s: str, t: str) -> int:
+ count_s = [0] * 26
+ count_t = [0] * 26
+
+ for char in s:
+ count_s[ord(char) - ord("a")] += 1
+
+ for char in t:
+ count_t[ord(char) - ord("a")] += 1
+
+ steps = 0
+ for i in range(0, 26):
+ steps += abs(count_s[i] - count_t[i])
+
+ return steps // 2
+
+
+def main():
+ solution = Solution()
+ print(solution.minSteps("bab", "aba"))
+ print(solution.minSteps("leetcode", "practice"))
+ print(solution.minSteps("anagram", "mangaar"))
+
+
+if __name__ == "__main__":
+ main()