python simple 36ms O(n) well commented
from collections import defaultdict\nclass Solution:\n    def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool:\n\t\n        #creating the ha
from collections import defaultdict\nclass Solution:\n    def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool:\n\t\n        #creating the hash map\n        dic=defaultdict(int)\n        \n        #mapping index of that element to element\n        for i,ele in enumerate(arr):dic[ele]=i\n            \n        #traversing through pieces\n        for i in pieces:\n            \n            #calculating its length and initializing , index variable to -1\n            n=len(i);ind=-1\n            \n            #traversing through elemnt array in pieces\n            for j in range(n):\n                #if the element was not in arr we can directly return False\n                if i[j] not in dic:\n                    return False\n                else:\n                    #if it is not the first element\n                    if ind!=-1:\n                        \n                        #if the element was not sucessor of the previous element in the arr then return False\n                        if ind+1!=dic[i[j]]:\n                            return False\n                    \n                    #assigning the new index to the index variable\n                    ind=dic[i[j]]\n        #if no case fails then return True\n        return True\n        \n
['Python3']