Swift | Using Dictionary
\nfunc canFormArray(_ arr: [Int], _ pieces: [[Int]]) -> Bool {\n    var dict : [Int:Int] = [:]\n    for i in 0..<pieces.count{\n        dict[pieces[i][0]] = i\n
```\nfunc canFormArray(_ arr: [Int], _ pieces: [[Int]]) -> Bool {\n    var dict : [Int:Int] = [:]\n    for i in 0..<pieces.count{\n        dict[pieces[i][0]] = i\n    }\n    var i = 0\n    while i < arr.count{\n        if dict[arr[i]] == nil{\n            return false\n        }\n        let a = pieces[dict[arr[i]]!]\n        for j in 0..<a.count{\n            if arr[i] != a[j]{\n                return false\n            }\n            i += 1\n        }\n    }\n    return true\n}\n```
['Swift']