結果 : greedy algorithm time and space complexity