Linear Solution with Hash Set