From d043c0971374e633c20f09231f824938ae698842 Mon Sep 17 00:00:00 2001 From: Manuel Pineda Date: Fri, 22 Jan 2021 20:30:00 +0100 Subject: [PATCH] [LeetCode] Add January 22. --- solved/LeetCode/Challenges/2020/January/22.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 solved/LeetCode/Challenges/2020/January/22.kt 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 + } +}