Leaf nodes from Preorder of a Binary Search Tree
Given Preorder traversal of a Binary Search Tree. Then the task is to print leaf nodes of the Binary Search Tree from the given preorder.Examples: Input: preorder[] = [4, 2, 1, 3, 6, 5]Output: [1, 3, 5]Explaination: 1, 3 and 5 are the leaf nodes as shown in the figure. Input: preorder[] = [5, 2, 10]