Why am I getting Memory Limit exceeded in this solution?

Revision en3, by sankalp_, 2018-07-15 11:50:03

I was solving a question which uses a trie and I've taken care of the number of nodes and I repeatedly got MLE upon implementing it using 2D arrays and pointers as well.

I've looked at submissions that used a similar logic and they are getting AC.

Any help as to why this is happening is highly appreciated.

Question : 514C

Submission with Pointers : Pointers

Similar submission : Also Pointers

Submission with 2D array : Array

Similar submission : Also Array

Sorry if I missed something obvious. I am legit stuck here and I can't figure out why this is happening. Can anyone please tell why?

[UPD]

The MLE was occurring because string str was being stored in the function stack multiple times and when the level of recursion becomes huge, it resulted in an MLE. Declaring the variable global solved it.

Accepted submissions :

Array

Pointers

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English sankalp_ 2018-07-15 11:50:03 386 Tiny change: '/40372222)' -> '/40372222)\n\nTha'
en2 English sankalp_ 2018-07-15 10:49:45 3 Tiny change: 'bvious. I legit stu' -> 'bvious. I am legit stu'
en1 English sankalp_ 2018-07-15 10:48:36 945 Initial revision (published)