CHEFINSQ problem

What’s the error in this?
My submission

line 15 is wrong

Can you tell me what’s wrong? I’m stuck.

You should explain how you came up with that formula

I actually used the same concept as mentioned in the discussion forum. In the first k elements, we remove all the z and look at the vacanies, y is the number of vacancies.

It’s not the same concept though, your y is different from theirs