My Accepted Swift Solutiın
\nclass Solution {\n    var idx:Int = 0\n    func buildTree(_ inorder: [Int], _ postorder: [Int]) -> TreeNode? {\n        if inorder.count != postorder.count {r
```\nclass Solution {\n    var idx:Int = 0\n    func buildTree(_ inorder: [Int], _ postorder: [Int]) -> TreeNode? {\n        if inorder.count != postorder.count {return nil}\n        if inorder.count == 0 {return nil}\n        idx = postorder.count - 1\n        return helper(inorder, postorder, 0, idx)\n    }\n    \n    func helper(_ inorder: [Int], _ postorder: [Int], _ start:Int, _ end: Int)-> TreeNode? {\n        if start > end {return nil}\n        let node = TreeNode(postorder[idx])\n        idx -= 1\n        if start == end { return node }\n        let index = findIdx(inorder, node.val, end)\n        node.right = helper(inorder, postorder, index+1, end)\n        node.left = helper(inorder, postorder, start, index-1)\n        return node\n    }\n    \n    func findIdx(_ inorder: [Int], _ val:Int, _ end:Int)->Int{\n        for i in (0...end).reversed(){\n            if inorder[i] == val{ return i }\n        }\n        return 0\n    }\n}\n```
['Swift']