✅✅ Python | 2 Different Approaches ✅✅
Approach 1: Hashmap\n\n\nclass Solution:\n    def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool:\n        d = {pair[0]: pair for pair in p
# Approach 1: Hashmap\n\n```\nclass Solution:\n    def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool:\n        d = {pair[0]: pair for pair in pieces}\n        i = 0\n        while i < len(arr):\n            if (arr[i] in d) and (arr[i:(n:=len(d[arr[i]]))+i] == d[arr[i]]):\n                i += n\n            else:\n                return False\n        return True\n\n```\n# Approach 2: Iteration through **"pieces"**\n```\nclass Solution:\n    def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool:\n        prev = 0\n        for i, num in enumerate(arr):\n            if arr[prev:i+1] in pieces:\n                prev = i+1\n        return prev == len(arr)\n\n```
['Array', 'Hash Table', 'Python3']