working lowest unique number soln in rb