Intuition

Join arrays into strings, compare if they are true and return.

Code

Python3

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

Big O Analysis

  • Runtime

    The runtime complexity here is since we are iterating the string once.

  • Memory

    The memory usage is since we are not using any extra data structure. It depends actually, since we are using the join function someone would say that it memory - since join returns a string.

— A

GitHub | Twitter