- We can use brute force to get it, use two for loop i and j, which i = 1:n and j = i:n. However, the time complexity is O(n^2), which is not efficient.
- Use hash table, the first thing is first store every element to table, then do traverse again to look up the table. Actually we can do it in one pass: every time look up the table, if meet the element we need, return it, otherwise store current element.