using hash to solve