In line no. 34 you have written -
str[m] = ‘P’;
which means if chef’s friend is marking proxy on that day then you are marking that day as present, but in the problem statement it is written that you can mark proxy only when chef is actually present on either of the previous days and either of the next two days which means you cannot take your previously marked proxy for marking proxy for next days which means you cannot change the original string.
so you basically need to remove this line from your code …
Hope this helps !!
thanks a lot
happy coding to you too sir…