Obvious answers would be:

- Sort both lists, then check each

element to see if they’re identical - Add the items from one array to a

hashtable, then iterate through the

other array, checking that each item

is in the hash - nickf’s iterative search algorithm

Which one you’d use would depend on whether you can sort the lists first, and whether you have a good hash algorithm handy.

### Related Contents:

- Unique (non-repeating) random numbers in O(1)?
- What is tail call optimization?
- What does O(log n) mean exactly?
- Equation (expression) parser with precedence?
- Segmented Sieve of Eratosthenes?
- Big-O for Eight Year Olds? [duplicate]
- How do I check if a number is a palindrome?
- Is it possible to express “t” variable from Cubic Bezier Curve equation?
- Generate all unique substrings for given string
- Algorithm to generate anagrams
- find all subsets that sum to a particular value
- What is the fastest algorithm to calculate the minimum distance between two sets of points?
- Algorithm to find next greater permutation of a given string
- Finding the best trade-off point on a curve
- How to delete in a heap data structure?
- SICP example: Counting change, cannot understand
- What is dynamic programming? [closed]
- Largest circle inside a non-convex polygon
- Check if one integer is an integer power of another
- How can I pair socks from a pile efficiently?
- “On-line” (iterator) algorithms for estimating statistical median, mode, skewness, kurtosis?
- How does Dijkstra’s Algorithm and A-Star compare?
- What string similarity algorithms are there?
- Find connected components in a graph [closed]
- Are there any cases where you would prefer a higher big-O time complexity algorithm over the lower one?
- How Do I Choose Between a Hash Table and a Trie (Prefix Tree)?
- Is there an algorithm that tells the semantic similarity of two phrases
- Find the paths between two given nodes?
- How to find two most distant points?
- Smooth spectrum for Mandelbrot Set rendering
- Calculate largest inscribed rectangle in a rotated rectangle
- Collision detection of huge number of circles
- Quicksort: Iterative or Recursive
- Algorithm for “nice” grid line intervals on a graph
- What algorithm to use to determine minimum number of actions required to get the system to “Zero” state?
- Why use Dijkstra’s Algorithm if Breadth First Search (BFS) can do the same thing faster?
- Undo/Redo implementation [closed]
- help in the Donalds B. Johnson’s algorithm, i cannot understand the pseudo code (PART II)
- Merge sort time and space complexity
- Finding how similar two strings are
- finding a^b^c^… mod m
- The sieve of Eratosthenes in F#
- Create non-intersecting polygon passing through all given points
- O(klogk) time algorithm to find kth smallest element from a binary heap
- What is the algorithm that opencv uses for finding contours?
- Enumerating all paths in a directed acyclic graph
- Find prime numbers using Scala. Help me to improve
- fitting n variable height images into 3 (similar length) column layout
- Finding height in Binary Search Tree
- Bits counting algorithm (Brian Kernighan) in an integer time complexity