iteration solution and greedy solution