FRMQ - Wrong Answer

This is the link to my solution.

If possible can anyone help me to fix my answer so that I can atleast get AC for subtask 2?