In the question : https://practice.geeksforgeeks.org/problems/construct-tree-1/1 which has been discuseed in the Binary Tree section by Prateek bhaiya, he first builds calls the function recursively to build the left subtree, then the right one.
When I tried to build it the other way around, i.e right subtree first and then the left subtree, it gave a segmentation fault as the preOrderIterator kept on increasing, and hence accessing the array went out of bounds.
I cannot seem to understand why we can’t do it the other way around.
For more information regarding the same, please refer to line 69 in the code below