Method 1) Hash Map
Put all the elements of first array in a Hash Map
Visit second array to check whether the values are same (that is the value already has exist in the hashmap or not) or different
Method 2) Brute Force
Compare each combination of elements in the graph. If a match found then assign the weight accordingly
Method 3) Sort and Search
Sort one array
For each element in one array, do a binary search of the element on second element

Leave a Reply
You must be logged in to post a comment.