Add non-recursive solution