Skip to content

Commit

Permalink
[LeetCode] Add January 22.
Browse files Browse the repository at this point in the history
  • Loading branch information
pin3da authored Jan 22, 2021
1 parent 0ab0d78 commit d043c09
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions solved/LeetCode/Challenges/2020/January/22.kt
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit d043c09

Please sign in to comment.