diff --git a/solved/LeetCode/Challenges/2020/January/22.kt b/solved/LeetCode/Challenges/2020/January/22.kt new file mode 100644 index 00000000..6fc7c3c3 --- /dev/null +++ b/solved/LeetCode/Challenges/2020/January/22.kt @@ -0,0 +1,11 @@ +class Solution { + fun closeStrings(A: String, B: String): Boolean { + val freqA = A.groupingBy { it }.eachCount() + val freqB = B.groupingBy { it }.eachCount() + val keysA = freqA.keys.sorted() + val keysB = freqB.keys.sorted() + val valA = freqA.values.sorted() + val valB = freqB.values.sorted() + return keysA == keysB && valA == valB + } +}