dp and recursive, swap, use hashtable to avoid swap with same number