Added solution with HashMap data structure T: O(n)