I’m getting an NZEC for this particular problem

My code works correctly for the test case stated in the problem though.
Here is my work:

Since i can’t figure out what might have caused an NZEC,it would be extremely helpful if anyone could figure it out and let me know the reason behind it.
Thank You.

I can’t seem to figure out the reason for NZEC, but I guess it’s due to the excessive memory your program uses, check here :

All the accepted JAVA solutions are within the memory limit of 256 MB, while your solution takes around 380 MB, I’d suggest changing your approach of taking string input or changing your programming language to C, C++. JAVA has a substantial overhead of around 178 MB due to its libraries which also makes it a little slow.
However, this problem doesn’t require large amount of memory as the constraints are very small.

Hope it helps.


Ouditchya Sinha.

@codegagu : Did my suggestion help? If so, kindly upvote it, if not please elaborate the new problems you are facing. :slight_smile: