Teamnet Interview Question

Implement an optimized loop for different problems.