Place the tiles

My code is giving run time error for the first two test cases.
Pls help.

My code : https://ide.codingblocks.com/s/179858

You are getting Runtime Error, because n can be very large ~100000000 you can not make this much size array. Try to do the problem without making a array. Think about storing the necessary state only.
You can contact me again if you cannot figure out how it can be done.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

This time I used map, but still its showing run time error. In map we can store any number of values. Then what is the problem with the code ?? Link : https://ide.codingblocks.com/s/180211

Sir pls resove my doubt

Sir I have solved the question successfully, but still it’s not showing green tick. Pls resolve the issue.

Please drop a mail at the [email protected] regarding the same and they’ll look into it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.