Many problems need a loop inside a loop: walking a grid, comparing every pair of items or printing star patterns. Patterns are the classic first test of whether you can link the inner loop's range to the outer loop's counter. Use nested loops when the work really is two-dimensional. Remember they often cost O(n²), so for large inputs a hash map or two pointers is usually expected instead.