FRMQ - Wrong Answer

array
frmq
tree

#1

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?