aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-13 05:00:34 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-13 05:00:34 +0000
commit4f5f4f076dd493310c14a83495296793aaba855e (patch)
tree5133ba200de72db2c9fd88d062578f61867419e2
parent1704 (diff)
downloadleetcode-4f5f4f076dd493310c14a83495296793aaba855e.tar.gz
leetcode-4f5f4f076dd493310c14a83495296793aaba855e.zip
1347
-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()