🎮 Battle Grid
0 /
0 cells visited
5
N (Grid Size)
0
Total Operations
N²
Complexity
💻 Loop Code
📚 Understanding Nested Loop Complexity
When you nest loops, the complexities multiply:
- O(N²): Two nested loops (i and j both go 0→N) = N × N operations
- O(N³): Three nested loops = N × N × N operations
- O(N log N): Loop where inner loop halves each time (like merge sort)
- O(N × M): Two loops with different bounds
Example: For N=5, O(N²) = 25 operations. For N=100, O(N²) = 10,000 operations!