Update 1.1: Method 1 added. By using a different data structure.

Hash table is used.