The idea is to use a resizable array (ArrayList in Java, vector in C) together with hashing. Resizable arrays support insert in Θ(1)
An efficient solution based on hash map is discussed. We need to check the Horizontal Distances from root for all nodes and two nodes have the same
Given two arrays: arr1[0..m-1] and arr2[0..n-1]. Find whether arr2 is a subset of arr1 or not. Both the arrays are not in sorted order.