leetcode

242. Valid Anagram

Alphabet solution code

_n = s, t _

Time complexity: O(n)

_k = alphabet = 26_

Space complexity: O(k)

Runtime 2 ms
Beats 97.08%

Memory 43.18 MB
Beats 68.41%

Map solution code

_n = s, t _

Time complexity: O(n)

Space complexity: O(n)

Runtime 14 ms
Beats 30.00%

Memory 44.30 MB
Beats 47.22%