While solving a Codeforces problem (Anton and Danik), I got Memory Limit Exceeded (MLE).
Code snippet:
int n, A=0, D=0;
char win[n]; // ❌ Problem here
scanf("%d", &n);
I declared:
char win[n];
before assigning a value to n.
At that moment:
n contains garbage value
C does NOT auto-initialize variables
So win[n] becomes something like:
char win[928374912]; // random number
If that random number is large:
When you write: