greed algorithm implemented