version with array and hash table as basic data structure