Please check the code tc 1 is failing

is your code giving runtime error ?

yes it is giving runtime error and testcase 0 is failing

please look into it…m struck

sorry for delay

make size of val array =s+1 not n+1
correct one

int* val=new int[s+1];