I was studying this https://www.geeksforgeeks.org/construct-tree-from-given-inorder-and-preorder-traversal/ but could not find a way to construct a binary tree using preorder and inorder with duplicate values because hashmaps and linear search does not work in some cases to find the right index. Please tell if there is an algorithm for this. Any kind of help would be appreciated.
Actually, we can't create a tree from inorder and preorder or inorder and postorder if the tree contains duplicate values.