Skip to main content

Practice · 3 of 3

Meet the allocation budget

CHALLENGE
Difficulty: advanced+25 XP

Implement static int[] Squares(int n) returning the squares 0..n-1 as a NEW array, and static int SumSquares(int n) computing the same total with ZERO heap allocations (a plain loop, no LINQ). The test enforces: Squares allocates ≤ n*8+64 bytes; SumSquares allocates exactly 0.

Back to lesson: Practice: Memory drills