Question 4 optimised match

optimised match using single level hash