The idea is to use a resizable array (ArrayList in Java, vector in C) together with hashing. Resizable arrays support insert in Θ(1)
Hashing
An Efficient Solution is to use the count of previous window, while sliding the window. The idea is to create a hash map that stores elements.
An Efficient Solution is to use the count of previous window, while sliding the window. The idea is to create a hash map that stores elements.
One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).
One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).
Given two Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists.
Given two Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists.
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 Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists.
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.