Optimization Problem In Algorithm