greedy algorithm, no fixed start or end point