You fixed that issue but now your basic test cases are failing. Like [1, 0, 1].
I see your fault. When you encounter the first ‘1’ you see another is 2 position ahead, so you update ans[c]=“NO”. But when you encounter the second ‘1’, it seems just fine, so you update ans[c] = “YES”.
I think you should break out of the main loop when you updated it to “NO” in the first place.