buildTree = function(preorder, inorder, max = -Infinity, indices = { preorder: 0, inorder: 0 }) {
    const isBaseCase = preorder.length <= indices.inorder;
    if (isBaseCase) return null;

    const isAtEnd = inorder[indices.inorder] === max;
    if (isAtEnd) {
        indices.inorder++;
        return null;
    }

    return dfs(preorder, inorder, max, indices);
}
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
Time O(N) | Space(H)
@param {number[]} preorder
@param {number[]} inorder
@return {TreeNode}