greedyAlgorithm