class Solution:
    # time:  O(n)
    # space: O(1)
    def isAnagram(self, s: str, t: str) -> bool:
        if len(s) != len(t):
            return False
        table = [0] * 26
        for c in s:
            table[ord(c) - ord("a")] += 1

        for c in t:
            idx = ord(c) - ord("a")
            table[idx] -= 1
            if table[idx] < 0:
                return False

        return True

    # def isAnagram(self, s: str, t: str) -> bool:
    #     if len(s) != len(t):
    #         return False
    #     table = {}
    #     for l in s:
    #         if l not in table:
    #             table[l] = 1
    #         else:
    #             table[l] += 1

    #     for l in t:
    #         if l not in table:
    #             return False
    #         table[l] -= 1
    #         if table[l] < 0:
    #             return False

    #     return True
