array and hashmap October 25, 2022

Check if two string arrays are equivalent

Time O(n) Space O(n) Open original problem

We will join the two arrays to strings and check if they are equal.

class Solution:
    def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
        return ''.join(word1) == ''.join(word2)

Time Complexity: O(n)
Space Complexity: O(n)